This fixes an incorrect detection that led to a formatting error.
Before:
some_var = function (*some_pointer_var)[0];
After:
some_var = function(*some_pointer_var)[0];
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186402
91177308-0d34-0410-b5e6-
96231b3b80d8
if (CurrentToken->is(tok::r_paren)) {
if (MightBeFunctionType && CurrentToken->Next &&
- CurrentToken->Next->isOneOf(tok::l_paren, tok::l_square))
+ (CurrentToken->Next->is(tok::l_paren) ||
+ (CurrentToken->Next->is(tok::l_square) &&
+ !Contexts.back().IsExpression)))
Left->Type = TT_FunctionTypeLParen;
Left->MatchingParen = CurrentToken;
CurrentToken->MatchingParen = Left;
// Other constructs can look somewhat like function types:
verifyFormat("A<sizeof(*x)> a;");
verifyFormat("#define DEREF_AND_CALL_F(x) f(*x)");
+ verifyFormat("some_var = function(*some_pointer_var)[0];");
+ verifyFormat("void f() { function(*some_pointer_var)[0] = 10; }");
}
TEST_F(FormatTest, BreaksLongDeclarations) {