Previously, we would not detect brace initializer lists in return
statements, thus:
return (a)(b) { 1, 2, 3 };
would put the semicolon onto the next line.
llvm-svn: 173017
case tok::kw_case:
parseCaseLabel();
return;
+ case tok::kw_return:
+ parseReturn();
+ return;
default:
break;
}
} while (!eof());
}
+void UnwrappedLineParser::parseReturn() {
+ nextToken();
+
+ do {
+ switch (FormatTok.Tok.getKind()) {
+ case tok::l_brace:
+ parseBracedList();
+ break;
+ case tok::l_paren:
+ parseParens();
+ break;
+ case tok::r_brace:
+ // Assume missing ';'.
+ addUnwrappedLine();
+ return;
+ case tok::semi:
+ nextToken();
+ addUnwrappedLine();
+ return;
+ default:
+ nextToken();
+ break;
+ }
+ } while (!eof());
+}
+
void UnwrappedLineParser::parseParens() {
assert(FormatTok.Tok.is(tok::l_paren) && "'(' expected.");
nextToken();
void parseComments();
void parseStructuralElement();
void parseBracedList();
+ void parseReturn();
void parseParens();
void parseIfThenElse();
void parseForOrWhileLoop();
"};", getLLVMStyleWithColumns(25));
}
+TEST_F(FormatTest, LayoutBraceInitializersInReturnStatement) {
+ verifyFormat("return (a)(b) { 1, 2, 3 };");
+}
+
TEST_F(FormatTest, LayoutTokensFollowingBlockInParentheses) {
verifyFormat(
"Aaa({\n"