Skip to content

Commit d8d47fa

Browse files
committed
Don't divide L and #x in macro definitions. Fixes http://llvm.org/PR17144
Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1639 llvm-svn: 190408
1 parent 6805de5 commit d8d47fa

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
12861286
return false;
12871287
if (Left.Type == TT_BlockComment && Left.TokenText.endswith("=*/"))
12881288
return false;
1289+
if (Right.is(tok::hash) && Left.is(tok::identifier) && Left.TokenText == "L")
1290+
return false;
12891291
return true;
12901292
}
12911293

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,7 @@ TEST_F(FormatTest, MacroDefinitionInsideStatement) {
19301930
}
19311931

19321932
TEST_F(FormatTest, HashInMacroDefinition) {
1933+
EXPECT_EQ("#define A(c) L#c", format("#define A(c) L#c", getLLVMStyle()));
19331934
verifyFormat("#define A \\\n b #c;", getLLVMStyleWithColumns(11));
19341935
verifyFormat("#define A \\\n"
19351936
" { \\\n"

0 commit comments

Comments
 (0)