diff options
author | Owen Pan <owenpiano@gmail.com> | 2019-04-18 20:17:08 +0000 |
---|---|---|
committer | Owen Pan <owenpiano@gmail.com> | 2019-04-18 20:17:08 +0000 |
commit | fb73b79a14d51692725d9159ccd040da7658f5f2 (patch) | |
tree | 06add35312005981b7e9d22036ed7884ccbcf2be | |
parent | 411a62403f7e1ce2f50ed7c1759ffd4697e3e27d (diff) | |
download | bcm5719-llvm-fb73b79a14d51692725d9159ccd040da7658f5f2.tar.gz bcm5719-llvm-fb73b79a14d51692725d9159ccd040da7658f5f2.zip |
[clang-format] Fix incorrect formatting of keyword macro definition
See PR39719
Differential Revision: https://reviews.llvm.org/D60853
llvm-svn: 358710
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 3760eb01959..64890d5333c 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -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(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 2ac0078dac9..be8566c7545 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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) { |