We used to incorrectly parse
aaaaaa ? aaaaaa(aaaaaa) :
aaaaaaaa;
Due to an l_paren being followed by a colon, we assumed it to be part of
a constructor initializer. Thus, we never found the colon belonging to
the conditional expression, marked the line as bing incorrect and did
not format it.
llvm-svn: 172621
break;
case tok::colon:
// Colons from ?: are handled in parseConditional().
+ if (Tok->Parent->is(tok::r_paren))
+ Tok->Type = TT_CtorInitializerColon;
if (ColonIsObjCMethodExpr)
Tok->Type = TT_ObjCMethodExpr;
break;
TT_ObjCMethodSpecifier;
if (!parseParens())
return false;
- if (CurrentToken != NULL && CurrentToken->is(tok::colon)) {
- CurrentToken->Type = TT_CtorInitializerColon;
- next();
- } else if (CurrentToken != NULL && ParensWereObjCReturnType) {
+ if (CurrentToken != NULL && ParensWereObjCReturnType) {
CurrentToken->Type = TT_ObjCSelectorStart;
next();
}
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
verifyFormat("aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa ?\n"
" aaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaa);");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa ? aaaa(aaaaaa) :\n"
+ " aaaaaaaaaaaaa);");
}
TEST_F(FormatTest, ConditionalExpressionsInBrackets) {