clang-format: Understand function type typedefs with typeof.

Before:
  typedef typeof(int(int, int)) * MyFunc;
After:
  typedef typeof(int(int, int)) *MyFunc;

This fixes llvm.org/PR17178.

llvm-svn: 190401
This commit is contained in:
Daniel Jasper 2013-09-10 10:26:38 +00:00
parent a9eb9972e4
commit 71665cd1fd
2 changed files with 6 additions and 0 deletions

View File

@ -745,6 +745,11 @@ private:
if (NextToken->is(tok::l_square))
return TT_PointerOrReference;
if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen &&
PrevToken->MatchingParen->Previous &&
PrevToken->MatchingParen->Previous->is(tok::kw_typeof))
return TT_PointerOrReference;
if (PrevToken->Tok.isLiteral() ||
PrevToken->isOneOf(tok::r_paren, tok::r_square) ||
NextToken->Tok.isLiteral() || NextToken->isUnaryOperator())

View File

@ -3765,6 +3765,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyIndependentOfContext("Type **A = static_cast<Type **>(P);");
verifyGoogleFormat("Type** A = static_cast<Type**>(P);");
verifyFormat("auto a = [](int **&, int ***) {};");
verifyFormat("typedef typeof(int(int, int)) *MyFunc;");
verifyIndependentOfContext("InvalidRegions[*R] = 0;");