Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

hnakamura5
Copy link
Contributor

The test I mentioned here #87450 .
This is a regression test to detect the case block type is not calculated due to the paste # operator misunderstood as preprocessor.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 7, 2024

@llvm/pr-subscribers-clang-format

Author: Hirofumi Nakamura (hnakamura5)

Changes

The test I mentioned here #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 --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");
 

Comment on lines +299 to +300
"}\n"
"multiclass MultiClass2<int i> { def : Def#x<i>; }\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the trailing newlines? There are dozens of them in this file. Please remove them if they are not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I come to notice that they are not required. I will make a patch for whole this file later.

@hnakamura5 hnakamura5 merged commit 5a855d5 into llvm:main Apr 8, 2024
6 checks passed
@hnakamura5
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants