-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-doc] Add regression test for test comments in macros #132360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| // RUN: rm -rf %t && mkdir -p %t | ||||||
| // RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s | ||||||
| // RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s | ||||||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass-LINE | ||||||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass | ||||||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass-LINE | ||||||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MyClass | ||||||
|
|
||||||
| #define DECLARE_METHODS \ | ||||||
| /** | ||||||
| * @brief Declare a method to calculate the sum of two numbers | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this comment is in the macro, did you intend it to be? Also as I understand it the bug wasn't filed about comments within macros, which I seldom see. But about comments attached to macros. I'd also suggest a simpler macro that doesn't define a full function (which also doesn't appear to actually be part of the macro.). Maybe the macro could be something like /// Your doc comments
#define ADD(a, b) a+b
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I intend to do it, because I try to restore code in issue. And I test some comment styles in this position, like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also rarely see this kind comment in comments, whether in books or in real projects. But this issue display like this. Maybe I understood this wrongly. If just regular comment, I think I can write a series test like enum.cpp. Maybe I'm overcomplicating the problem.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ah, no, I've confused this with a different issue. Apologies. I should take my own advice not to review code first thing in the morning XD. Lets just make it syntactically correct using trailing You can confirm what's going on by dumping the AST from clang, or by using some of the debug output from clang-doc.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sense. I will report something as new issues, or maybe I can write it in my GSoC proposal? I will fix these files after wake up, because it is already early morning here, and I think I broken up something in the project, so I re-cloned entire project, and even though I used I am very happy to get your help and learn new knowledge on the first day of contacting the project, even though I messed up some things. |
||||||
| */ \ | ||||||
| int Add(int a, int b) \ | ||||||
| { \ | ||||||
| return a + b; \ | ||||||
| } | ||||||
|
|
||||||
| // MD-MyClass: ### Add | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Use all caps for check prefixes |
||||||
| // MD-MyClass: *public int Add(int a, int b)* | ||||||
| // MD-MyClass: **brief** Declare a method to calculate the sum of two numbers | ||||||
|
|
||||||
| // HTML-MyClass: <p>public int Add(int a, int b)</p> | ||||||
| // HTML-MyClass: <div>brief</div> | ||||||
| // HTML-MyClass: <p> Declare a method to calculate the sum of two numbers</p> | ||||||
|
|
||||||
|
|
||||||
| class MyClass { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this class testing? It's not clear what property you're trying to exercise. I see you expect the macro to expand in the class, but I don't think you're testing what you think you are.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I didn't use this class, in this style comment, generated content will no this macro, both html and markdown. That why I use a . And again, I try to restore issue example in issue, so I use this style comment. I also think this class shouldn't be here, but I don't know how to implement a macro function like in issue. |
||||||
| public: | ||||||
| // MD-MyClass-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp#[[@LINE+2]]* | ||||||
| // HTML-MyClass-LINE: <p>Defined at line [[@LINE+1]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp</p> | ||||||
| DECLARE_METHODS | ||||||
| }; | ||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0024 | ||
| 509d326cf43a00f4244e32ee2f04c3e2 | ||
| ../../opt/cuda/bin/ptxas | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0030 | ||
| d830f4e83fadc0198bcd16cda139c2ab | ||
| i386-unknown-linux-gnu-ld.gold | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0032 | ||
| dc3942b3625b5edbceda2054b487f4cf | ||
| x86_64-unknown-linux-gnu-ld.gold | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0007 | ||
| a4a6106fa60c6a126bf88b36f82eca45 | ||
| ld.gold | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0007 | ||
| a4a6106fa60c6a126bf88b36f82eca45 | ||
| ld.gold | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0006 | ||
| 75027f59be28a4783c4dbb6f47c0ce72 | ||
| ld.lld | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0025 | ||
| f706cb75cd2a1eeaf3cc4516f97ca07a | ||
| i386-unknown-linux-gnu-as | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0025 | ||
| fae188f0b438aa0ee85bf296c22d408d | ||
| i386-unknown-linux-gnu-ld | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0035 | ||
| cc3d89dc47131fa307b744805fdeb87b | ||
| ../../bin/i386-unknown-linux-gnu-as | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0035 | ||
| 6693f8726305d07602737a435e2b8a22 | ||
| ../../bin/i386-unknown-linux-gnu-ld | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0027 | ||
| 4b879674be084ecc7a2574cf9f69ec98 | ||
| x86_64-unknown-linux-gnu-as | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0027 | ||
| acddaea92e9f2581b0940c29f8726108 | ||
| x86_64-unknown-linux-gnu-ld | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0037 | ||
| 4237f2b716c4c66e0a5a9d62e2947704 | ||
| ../../bin/x86_64-unknown-linux-gnu-as | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0037 | ||
| c87e4c3470038094e85a9724945b6b54 | ||
| ../../bin/x86_64-unknown-linux-gnu-ld | ||
|
|
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| XSym | ||
| 0013 | ||
| 64f134e8c57126ca56932a494eb70be5 | ||
| ../real/foo.h | ||
|
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets move this down w/ the HTML FileCheck lines so they're grouped together.
I'd also suggest renaming the test file to DR-59819.cpp, which is a common way to indicate that its a regression test (DR stands for Defect Report, and the number is the issue number. I'm fine to leave it with a more readable name, but in that case I'd prefer
comments-in-macros.cppand a comment at the top of the file describing the purpose and properties you're testing for.