Author: owenpan Date: Thu Apr 18 13:17:08 2019 New Revision: 358710 URL: http://llvm.org/viewvc/llvm-project?rev=358710&view=rev Log: [clang-format] Fix incorrect formatting of keyword macro definition
See PR39719 Differential Revision: https://reviews.llvm.org/D60853 Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=358710&r1=358709&r2=358710&view=diff ============================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Apr 18 13:17:08 2019 @@ -805,7 +805,7 @@ void UnwrappedLineParser::parsePPEndIf() void UnwrappedLineParser::parsePPDefine() { nextToken(); - if (FormatTok->Tok.getKind() != tok::identifier) { + if (!FormatTok->Tok.getIdentifierInfo()) { IncludeGuard = IG_Rejected; IncludeGuardToken = nullptr; parsePPUnknown(); Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=358710&r1=358709&r2=358710&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Apr 18 13:17:08 2019 @@ -2468,6 +2468,12 @@ TEST_F(FormatTest, HashInMacroDefinition TEST_F(FormatTest, RespectWhitespaceInMacroDefinitions) { EXPECT_EQ("#define A (x)", format("#define A (x)")); EXPECT_EQ("#define A(x)", format("#define A(x)")); + + FormatStyle Style = getLLVMStyle(); + Style.SpaceBeforeParens = FormatStyle::SBPO_Never; + verifyFormat("#define true ((foo)1)", Style); + Style.SpaceBeforeParens = FormatStyle::SBPO_Always; + verifyFormat("#define false((foo)0)", Style); } TEST_F(FormatTest, EmptyLinesInMacroDefinitions) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits