Formatter: * and & are binary operators after ) and ].

llvm-svn: 172302
This commit is contained in:
Nico Weber 2013-01-12 05:47:16 +00:00
parent 63a54eb766
commit 5dafd4a7ae
2 changed files with 4 additions and 1 deletions

View File

@ -969,7 +969,8 @@ private:
Tok.Parent->Type == TT_CastRParen)
return TT_UnaryOperator;
if (PrevToken.Tok.isLiteral() || NextToken.Tok.isLiteral() ||
if (PrevToken.Tok.isLiteral() || PrevToken.Tok.is(tok::r_paren) ||
PrevToken.Tok.is(tok::r_square) || NextToken.Tok.isLiteral() ||
NextToken.Tok.is(tok::plus) || NextToken.Tok.is(tok::minus) ||
NextToken.Tok.is(tok::plusplus) || NextToken.Tok.is(tok::minusminus) ||
NextToken.Tok.is(tok::tilde) || NextToken.Tok.is(tok::exclaim) ||

View File

@ -1014,6 +1014,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("a * -b;");
verifyFormat("a * ++b;");
verifyFormat("a * --b;");
verifyFormat("a[4] * b;");
verifyFormat("f() * b;");
verifyFormat("int *pa = (int *)&a;");
verifyFormat("InvalidRegions[*R] = 0;");