Skip to content

Commit 3449ed8

Browse files
committed
Revert "[clang-format] Correctly annotate braces in macro definition (#106662)"
This reverts commit 0fa78b6 due to regression. Fixes #107096.
1 parent 4a44898 commit 3449ed8

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
609609
ProbablyBracedList = NextTok->isNot(tok::l_square);
610610
}
611611

612-
// Cpp macro definition body containing nonempty braced list or block:
612+
// Cpp macro definition body that is a nonempty braced list or block:
613613
if (IsCpp && Line->InMacroBody && PrevTok != FormatTok &&
614+
!FormatTok->Previous && NextTok->is(tok::eof) &&
614615
// A statement can end with only `;` (simple statement), a block
615616
// closing brace (compound statement), or `:` (label statement).
616617
// If PrevTok is a block opening brace, Tok ends an empty block.

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3278,11 +3278,6 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
32783278
EXPECT_BRACE_KIND(Tokens[10], BK_Block);
32793279
EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace);
32803280
EXPECT_BRACE_KIND(Tokens[11], BK_Block);
3281-
3282-
Tokens = annotate("#define MEMBER(NAME) NAME{\"\"}");
3283-
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
3284-
EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit);
3285-
EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit);
32863281
}
32873282

32883283
TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {

0 commit comments

Comments
 (0)