[clang-tools-extra] [clang-doc] Add regression test for test comments in macros (PR #132510)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 15 08:50:08 PDT 2025


================
@@ -0,0 +1,35 @@
+// Regression test for https://github.com/llvm/llvm-project/issues/59819
+
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=md --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: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// 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\
+     */                                                           \
+    int Add(int a, int b) {                                       \
+        return a + b;                                             \
+    }
+
+// MD-MYCLASS: ### Add
+// 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 {
+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>
----------------
ZhongUncle wrote:

> The line number seems to not be where you expect in the test. Does this pass for you locally?

The line number is relative position, they are correct. 

Not passed may be due to `\` in EOL of comment. We talked about it in previous cloesd issue https://github.com/llvm/llvm-project/pull/132360#discussion_r2007941750. 

If I add `\`to each EOL in comment, it will generate some `\` in doc generated. So it doesn't passed. You said I can add `\` to each EOL, and report it as a new issue.

https://github.com/llvm/llvm-project/pull/132510


More information about the cfe-commits mailing list