release/19.x: [clang-format] Correctly annotate braces in macro definitions (#123279) by llvmbot · Pull Request #123439 · llvm/llvm-project (original) (raw)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index e3fb976ee1cc44..eb520870bb7708 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -505,14 +505,14 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { auto *NextTok = Tokens->getNextNonComment();

 if (!Line->InMacroBody && !Style.isTableGen()) {

diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 7b2947acea4a2e..e3daac5a23359f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5725,23 +5725,12 @@ TEST_F(FormatTest, HashInMacroDefinition) {

verifyFormat("#define A void # ## #", getLLVMStyleWithColumns(22));

-#if 0

-#endif

}

TEST_F(FormatTest, RespectWhitespaceInMacroDefinitions) { diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 7d4ff3dfa32490..8f7f86d401edf0 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -3214,14 +3214,27 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[0], BK_Block); EXPECT_TOKEN(Tokens[1], tok::l_brace, TT_BlockLBrace); EXPECT_BRACE_KIND(Tokens[1], BK_Block); -#if 0