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

via cfe-commits cfe-commits at lists.llvm.org
Sun May 4 01:52:41 PDT 2025


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

>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/7] 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/7] 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/7] 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
 };
 
-

>From 875938cfe12900d93b95ef993c9257522de843f7 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738339 at qq.com>
Date: Tue, 25 Mar 2025 11:36:19 +0800
Subject: [PATCH 4/7] 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 | 4 ++--
 1 file changed, 2 insertions(+), 2 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 3273ddcd9c92c..4a9a8c23d33d8 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -3,6 +3,7 @@
 // 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
@@ -11,8 +12,7 @@
     /**   							  \
      * @brief Declare a method to calculate the sum of two numbers\
      */                                                           \
-    int Add(int a, int b)                                         \
-    {                                                             \
+    int Add(int a, int b) {                                       \
         return a + b;                                             \
     }
 

>From 7bad1992dcc8852f59215cbb2f5d0a96c43a1b18 Mon Sep 17 00:00:00 2001
From: ZhongUncle <78771985+ZhongUncle at users.noreply.github.com>
Date: Thu, 3 Apr 2025 00:58:15 +0800
Subject: [PATCH 5/7] Update
 clang-tools-extra/test/clang-doc/comments-in-macros.cpp

Co-authored-by: Paul Kirth <paulkirth at google.com>
---
 clang-tools-extra/test/clang-doc/comments-in-macros.cpp | 3 ++-
 1 file changed, 2 insertions(+), 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 4a9a8c23d33d8..8da765dfb9913 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -1,4 +1,5 @@
-// Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test.
+// 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

>From 9e9fdf6671a3425b31f8f6ccca4d4ff5bf7b4818 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738339 at qq.com>
Date: Sat, 19 Apr 2025 20:15:34 +0800
Subject: [PATCH 6/7] 	modified:   comments-in-macros.cpp

---
 clang-tools-extra/test/clang-doc/comments-in-macros.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 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 8da765dfb9913..a09deff97f446 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -28,8 +28,8 @@
 
 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{{[\/]}}comments-in-macros.cpp#[[@LINE+2]]*
+// HTML-MYCLASS-LINE: <p>Defined at line [[@LINE+1]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp</p>
     DECLARE_METHODS
 };
 

>From f9cd05d79e13d1c738d2f2875b1828fc9cc691db Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738339 at qq.com>
Date: Sun, 4 May 2025 16:51:54 +0800
Subject: [PATCH 7/7] 	modified:   comments-in-macros.cpp

---
 clang-tools-extra/test/clang-doc/comments-in-macros.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 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 a09deff97f446..0c70fadb7f9ac 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -10,8 +10,8 @@
 // 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\
+    /**   							  
+     * @brief Declare a method to calculate the sum of two numbers
      */                                                           \
     int Add(int a, int b) {                                       \
         return a + b;                                             \



More information about the cfe-commits mailing list