Skip to content

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented Sep 3, 2024

Backport 0fa78b6

Requested by: @owenca

@llvmbot llvmbot added this to the LLVM 19.X Release milestone Sep 3, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Sep 3, 2024

@HazardyKnusperkeks What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Sep 3, 2024

@llvm/pr-subscribers-clang-format

Author: None (llvmbot)

Changes

Backport 0fa78b6

Requested by: @owenca


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

2 Files Affected:

  • (modified) clang/lib/Format/UnwrappedLineParser.cpp (+1-2)
  • (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+5)
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 7f5d157ae95891..60e65aaa83e9c1 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -609,9 +609,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
             ProbablyBracedList = NextTok->isNot(tok::l_square);
           }
 
-          // Cpp macro definition body that is a nonempty braced list or block:
+          // Cpp macro definition body containing nonempty braced list or block:
           if (IsCpp && Line->InMacroBody && PrevTok != FormatTok &&
-              !FormatTok->Previous && NextTok->is(tok::eof) &&
               // A statement can end with only `;` (simple statement), a block
               // closing brace (compound statement), or `:` (label statement).
               // If PrevTok is a block opening brace, Tok ends an empty block.
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index f0533c92f6538c..db580d70058811 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3218,6 +3218,11 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_BRACE_KIND(Tokens[10], BK_Block);
   EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace);
   EXPECT_BRACE_KIND(Tokens[11], BK_Block);
+
+  Tokens = annotate("#define MEMBER(NAME) NAME{\"\"}");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit);
+  EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {

@tru tru merged commit 2d90e8f into llvm:release/19.x Sep 3, 2024
@github-actions
Copy link

github-actions bot commented Sep 3, 2024

@owenca (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

@prj-
Copy link

prj- commented Sep 3, 2024

Are you sure about this fix? 20240831100704+8aa8c0590c09-1~exp1~20240831220720.2307 is clean, 19 RC4 is clean, but 20240902101259+0ba006daf5d9-1~exp1~20240902221440.2311 is not, see #107096.
Since this has now been merged in llvm:release/19.x, it would mean that 19.1.0 would not been clean as well?

@prj-
Copy link

prj- commented Sep 4, 2024

@tru, this introduced what looks like a (confirmed) regression, see #107096 (comment). Could this be reverted?

@owenca
Copy link
Contributor

owenca commented Sep 4, 2024

@tru, this introduced what looks like a (confirmed) regression, see #107096 (comment). Could this be reverted?

I've reverted 0fa78b6 with 3449ed8. I agree that we should do the same for 19.x.

@owenca
Copy link
Contributor

owenca commented Sep 5, 2024

Alternatively, we can backport #107352.

@owenca
Copy link
Contributor

owenca commented Sep 6, 2024

@tru, I've created #107531 which reverts 2d90e8f and backports #107352.

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

Projects

Development

Successfully merging this pull request may close these issues.

4 participants