[clang] [clang-format] Added unittest of TableGen formatting w.r.t. block type calculation. (PR #87924)

via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 7 06:44:03 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-format

Author: Hirofumi Nakamura (hnakamura5)

<details>
<summary>Changes</summary>

The test I mentioned here https://github.com/llvm/llvm-project/pull/87450 .
This is a regression test to detect the case block type is not calculated due to the paste `#` operator misunderstood as preprocessor. 

---
Full diff: https://github.com/llvm/llvm-project/pull/87924.diff


1 Files Affected:

- (modified) clang/unittests/Format/FormatTestTableGen.cpp (+10) 


``````````diff
diff --git a/clang/unittests/Format/FormatTestTableGen.cpp b/clang/unittests/Format/FormatTestTableGen.cpp
index 8ca6bf97e5a6b1..d235c85c8eaa0f 100644
--- a/clang/unittests/Format/FormatTestTableGen.cpp
+++ b/clang/unittests/Format/FormatTestTableGen.cpp
@@ -290,6 +290,16 @@ TEST_F(FormatTestTableGen, MultiClass) {
                "}\n");
 }
 
+TEST_F(FormatTestTableGen, MultiClassesWithPasteOperator) {
+  // This is a sensitive example for the handling of the paste operators in
+  // brace type calculation.
+  verifyFormat("multiclass MultiClass1<int i> {\n"
+               "  def : Def#x<i>;\n"
+               "  def : Def#y<i>;\n"
+               "}\n"
+               "multiclass MultiClass2<int i> { def : Def#x<i>; }\n");
+}
+
 TEST_F(FormatTestTableGen, Defm) {
   verifyFormat("defm : Multiclass<0>;\n");
 

``````````

</details>


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


More information about the cfe-commits mailing list