Don't format sizeof/alignof as function types.

Before: A<sizeof (*x)> a;
After:  A<sizeof(*x)> a;
llvm-svn: 181764
This commit is contained in:
Daniel Jasper 2013-05-14 08:34:47 +00:00
parent 9d987e34f7
commit abc342148f
2 changed files with 7 additions and 1 deletions

View File

@ -173,7 +173,9 @@ private:
}
if (CurrentToken->isOneOf(tok::r_square, tok::r_brace))
return false;
if (CurrentToken->Parent->Type == TT_PointerOrReference &&
if (Left->Parent &&
!Left->Parent->isOneOf(tok::kw_sizeof, tok::kw_alignof) &&
CurrentToken->Parent->Type == TT_PointerOrReference &&
CurrentToken->Parent->Parent->isOneOf(tok::l_paren, tok::coloncolon))
Left->DefinesFunctionType = true;
updateParameterCount(Left, CurrentToken);

View File

@ -2790,6 +2790,10 @@ TEST_F(FormatTest, FormatsFunctionTypes) {
verifyGoogleFormat("A<void*(int*, SomeType*)>;");
verifyGoogleFormat("void* (*a)(int);");
// Other constructs can look like function types:
verifyFormat("A<sizeof(*x)> a;");
verifyFormat("A<alignof(*x)> a;");
}
TEST_F(FormatTest, BreaksLongDeclarations) {