Fix handling of macro definitions.

Now correctly formats:
 #define A (1)

llvm-svn: 173264
This commit is contained in:
Manuel Klimek 2013-01-23 14:37:36 +00:00
parent d1bfdc32b2
commit d053c5b43a
2 changed files with 6 additions and 1 deletions

View File

@ -240,7 +240,8 @@ void UnwrappedLineParser::parsePPDefine() {
return;
}
nextToken();
if (FormatTok.Tok.getKind() == tok::l_paren) {
if (FormatTok.Tok.getKind() == tok::l_paren &&
FormatTok.WhiteSpaceLength == 0) {
parseParens();
}
addUnwrappedLine();

View File

@ -742,6 +742,10 @@ TEST_F(FormatTest, HashInMacroDefinition) {
verifyFormat("#define A void # ## #", getLLVMStyleWithColumns(22));
}
TEST_F(FormatTest, RespectWhitespaceInMacroDefinitions) {
verifyFormat("#define A (1)");
}
TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {
EXPECT_EQ("{\n {\n#define A\n }\n}", format("{{\n#define A\n}}"));
}