Correctly format dereference and address of in array parameters.

Before: InvalidRegions[ &R] = 0;
After:  InvalidRegions[&R] = 0;

This fixes llvm.org/PR14793

llvm-svn: 171522
This commit is contained in:
Daniel Jasper 2013-01-04 20:46:38 +00:00
parent 66748e93e2
commit 3c2557d0dd
2 changed files with 5 additions and 2 deletions

View File

@ -878,8 +878,9 @@ private:
const FormatToken &PrevToken = Line.Tokens[Index - 1];
const FormatToken &NextToken = Line.Tokens[Index + 1];
if (PrevToken.Tok.is(tok::l_paren) || PrevToken.Tok.is(tok::comma) ||
PrevToken.Tok.is(tok::kw_return) || PrevToken.Tok.is(tok::colon) ||
if (PrevToken.Tok.is(tok::l_paren) || PrevToken.Tok.is(tok::l_square) ||
PrevToken.Tok.is(tok::comma) || PrevToken.Tok.is(tok::kw_return) ||
PrevToken.Tok.is(tok::colon) ||
Annotations[Index - 1].Type == TokenAnnotation::TT_BinaryOperator)
return TokenAnnotation::TT_UnaryOperator;

View File

@ -768,6 +768,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("a * ++b;");
verifyFormat("a * --b;");
verifyFormat("InvalidRegions[*R] = 0;");
// FIXME: Is this desired for LLVM? Fix if not.
verifyFormat("A<int *> a;");
verifyFormat("A<int **> a;");