Skip to content

Commit

Permalink
Revert "[clang-format] Correctly annotate braces in macro definition (#…
Browse files Browse the repository at this point in the history
…106662)"

This reverts commit 0fa78b6 due to
regression.

Fixes #107096.
  • Loading branch information
owenca committed Sep 4, 2024
1 parent 4a44898 commit 3449ed8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 2 additions & 1 deletion clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,9 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
ProbablyBracedList = NextTok->isNot(tok::l_square);
}

// Cpp macro definition body containing nonempty braced list or block:
// Cpp macro definition body that is a 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.
Expand Down
5 changes: 0 additions & 5 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3278,11 +3278,6 @@ 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) {
Expand Down

0 comments on commit 3449ed8

Please sign in to comment.