clang-format: Fix unary operator recognition.

Before:
  int x = ~ * p;

After:
  int x = ~*p;

llvm-svn: 214070
This commit is contained in:
Daniel Jasper 2014-07-28 12:08:16 +00:00
parent 8b76d608b8
commit 2ac3fdfd4a
2 changed files with 2 additions and 1 deletions

View File

@ -755,7 +755,7 @@ private:
Contexts.back().CaretFound = true; Contexts.back().CaretFound = true;
} else if (Current.isOneOf(tok::minusminus, tok::plusplus)) { } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) {
Current.Type = determineIncrementUsage(Current); Current.Type = determineIncrementUsage(Current);
} else if (Current.is(tok::exclaim)) { } else if (Current.isOneOf(tok::exclaim, tok::tilde)) {
Current.Type = TT_UnaryOperator; Current.Type = TT_UnaryOperator;
} else if (Current.is(tok::question)) { } else if (Current.is(tok::question)) {
Current.Type = TT_ConditionalExpr; Current.Type = TT_ConditionalExpr;

View File

@ -4766,6 +4766,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyIndependentOfContext("typedef void (*f)(int *a);"); verifyIndependentOfContext("typedef void (*f)(int *a);");
verifyIndependentOfContext("int i{a * b};"); verifyIndependentOfContext("int i{a * b};");
verifyIndependentOfContext("aaa && aaa->f();"); verifyIndependentOfContext("aaa && aaa->f();");
verifyIndependentOfContext("int x = ~*p;");
verifyIndependentOfContext("InvalidRegions[*R] = 0;"); verifyIndependentOfContext("InvalidRegions[*R] = 0;");