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

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 21 20:51:56 PDT 2025


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

Fixes https://github.com/llvm/llvm-project/issues/59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test.

I am not familiar with PR, so accidentally closed the previous PR. This is a new one.

>From a6a1916aba2d6e42ab7d5f110752a36ecf3268e8 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738339 at qq.com>
Date: Sat, 22 Mar 2025 11:29:20 +0800
Subject: [PATCH 1/3] Fixes #59819. The underlying problem was fixed in
 https://reviews.llvm.org/D142560, but this patch adds a proper regression
 test.

---
 .../test/clang-doc/comments-in-macros.cpp     | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/comments-in-macros.cpp

diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
new file mode 100644
index 0000000000000..5dbb20eca6ae1
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -0,0 +1,35 @@
+// Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test.
+// 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\
+     */                                                           \
+    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>
+    DECLARE_METHODS
+};
+
+

>From b15a9d0d97bacb6df133c3c4c5c1c090069672d2 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738339 at qq.com>
Date: Sat, 22 Mar 2025 11:44:29 +0800
Subject: [PATCH 2/3] Fixes #59819. The underlying problem was fixed in
 https://reviews.llvm.org/D142560, but this patch adds a proper regression
 test.

---
 clang-tools-extra/test/clang-doc/comments-in-macros.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
index 5dbb20eca6ae1..24ad21eff164d 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -1,9 +1,9 @@
 // Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test.
 // 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: 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
 

>From 2b6556e554f0245734c2cade64d23a849efe6176 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738339 at qq.com>
Date: Sat, 22 Mar 2025 11:50:47 +0800
Subject: [PATCH 3/3] Fixes #59819. The underlying problem was fixed in
 https://reviews.llvm.org/D142560, but this patch adds a proper regression
 test.

---
 .../test/clang-doc/comments-in-macros.cpp     | 25 +++++++++----------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
index 24ad21eff164d..3273ddcd9c92c 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -1,11 +1,11 @@
 // Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test.
 // 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: 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
+// 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                                           \
     /**   							  \
@@ -16,20 +16,19 @@
         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
+// 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>
+// 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>
+// 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
 };
 
-



More information about the cfe-commits mailing list