[PATCH] D60853: clang-format incorrectly inserts a space after a macro function name that is a keyword
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 17 22:38:18 PDT 2019
owenpan created this revision.
owenpan added reviewers: klimek, djasper, reuk, russellmcc, sammccall, MyDeveloperDay.
owenpan added a project: clang.
Herald added a subscriber: cfe-commits.
See https://bugs.llvm.org/show_bug.cgi?id=39719 and discussion: https://reviews.llvm.org/D60362
Repository:
rC Clang
https://reviews.llvm.org/D60853
Files:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2468,6 +2468,12 @@
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) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -805,7 +805,7 @@
void UnwrappedLineParser::parsePPDefine() {
nextToken();
- if (FormatTok->Tok.getKind() != tok::identifier) {
+ if (!FormatTok->Tok.getIdentifierInfo()) {
IncludeGuard = IG_Rejected;
IncludeGuardToken = nullptr;
parsePPUnknown();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60853.195675.patch
Type: text/x-patch
Size: 1173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190418/67eb3d0e/attachment.bin>
More information about the cfe-commits
mailing list