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

Hirofumi Nakamura via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 7 06:43:32 PDT 2024


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

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. 

>From fd10ce8a2d6532052c240d385f263602b859ff7a Mon Sep 17 00:00:00 2001
From: hnakamura5 <k.nakamura.hirofumi at gmail.com>
Date: Sun, 7 Apr 2024 22:32:31 +0900
Subject: [PATCH] [clang-format] Added unittest of TableGen formatting w.r.t.
 block kind

---
 clang/unittests/Format/FormatTestTableGen.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

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");
 



More information about the cfe-commits mailing list