[clang] 3449ed8 - Revert "[clang-format] Correctly annotate braces in macro definition (#106662)"
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 22:54:59 PDT 2024
Author: Owen Pan
Date: 2024-09-03T22:54:50-07:00
New Revision: 3449ed8dece600f387357b71ff74ae4bc46828b6
URL: https://github.com/llvm/llvm-project/commit/3449ed8dece600f387357b71ff74ae4bc46828b6
DIFF: https://github.com/llvm/llvm-project/commit/3449ed8dece600f387357b71ff74ae4bc46828b6.diff
LOG: Revert "[clang-format] Correctly annotate braces in macro definition (#106662)"
This reverts commit 0fa78b6c7bd43c2498700a98c47a02cf4fd06388 due to
regression.
Fixes #107096.
Added:
Modified:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 0d42a6c2bfb5c6..246b29d308bfaf 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -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.
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index a2986f589396b4..c0436d8a2e180a 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -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) {
More information about the cfe-commits
mailing list