[clang-doc] Add regression test for test comments in macros by ZhongUncle · Pull Request #132510 · llvm/llvm-project (original) (raw)

So does ninja check-clang-extra-clang-doc pass w/ your changes?

No, it doesn't passed w/ my change. I also test it via llvm-lit llvm-project/clang-tools-extra/test/clang-doc/.

Because below code

#define DECLARE_METHODS                                           \
    /**                                                           \
     * @brief Declare a method to calculate the sum of two numbers\
     */                                                           \
    int Add(int a, int b) {                                       \
        return a + b;                                             \
    }

will generate something like below (there are additional \ appearing):

\    
Declare a method to calculate the sum of two numbers\

rather than correct content generated:

Declare a method to calculate the sum of two numbers

But I test it using correct content generated. It is why not pass test. They don't match, so not pass.

We discussed this rare comment style before, and you suggested that I add a \ to each EOL, because it is example in #59819. But recently, I noticed via the editor highlighting that if you add a \, it will be considered as a character in the comment, rather than indicating the comment as a whole. If you add a \, it will be considered as a character in the comment.

Below image is in vim, you can see color of \ is same as comment (I also test it in VS Code, same highlight):
截屏2025-04-17 14 39 51

So I don't think that it is issues of other feature. The problem is our example.

At beginning, I use this kind of comment

#define DECLARE_METHODS                                           \
    /**                                                           
     * @brief Declare a method to calculate the sum of two numbers
     */                                                           \
    int Add(int a, int b) {                                       \
        return a + b;                                             \
    }

It passed test. So I think: Should I change code like above?

Well, its a test, so it needs to be correct w.r.t. the thing you're testing, and shouldn't be broken overall (or at least not broken in a new way).

Oh, make sense. I will remove this line check in Class. I checked the line numbers here because I saw it written in other tests, so I thought I had to check all the key parts.