@@ -2534,6 +2534,7 @@ bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) {
25342534bool UnwrappedLineParser::parseParens (TokenType AmpAmpTokenType) {
25352535 assert (FormatTok->is (tok::l_paren) && " '(' expected." );
25362536 auto *LeftParen = FormatTok;
2537+ bool SeenComma = false ;
25372538 bool SeenEqual = false ;
25382539 bool MightBeFoldExpr = false ;
25392540 const bool MightBeStmtExpr = Tokens->peekNextToken ()->is (tok::l_brace);
@@ -2553,10 +2554,14 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
25532554 const auto *Next = Tokens->peekNextToken ();
25542555 const bool DoubleParens =
25552556 Prev && Prev->is (tok::l_paren) && Next && Next->is (tok::r_paren);
2557+ const bool CommaSeparated =
2558+ !DoubleParens && Prev && Prev->isOneOf (tok::l_paren, tok::comma) &&
2559+ Next && Next->isOneOf (tok::comma, tok::r_paren);
25562560 const auto *PrevPrev = Prev ? Prev->getPreviousNonComment () : nullptr ;
2557- const bool Disallowed =
2561+ const bool Excluded =
25582562 PrevPrev &&
25592563 (PrevPrev->isOneOf (tok::kw___attribute, tok::kw_decltype) ||
2564+ SeenComma ||
25602565 (SeenEqual &&
25612566 (PrevPrev->isOneOf (tok::kw_if, tok::kw_while) ||
25622567 PrevPrev->endsSequence (tok::kw_constexpr, tok::kw_if))));
@@ -2566,7 +2571,8 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
25662571 (!NestedLambdas.empty () && !NestedLambdas.back ())) &&
25672572 Prev && Prev->isOneOf (tok::kw_return, tok::kw_co_return) && Next &&
25682573 Next->is (tok::semi);
2569- if ((DoubleParens && !Disallowed) || ReturnParens) {
2574+ if ((DoubleParens && !Excluded) || (CommaSeparated && !SeenComma) ||
2575+ ReturnParens) {
25702576 LeftParen->Optional = true ;
25712577 FormatTok->Optional = true ;
25722578 }
@@ -2595,6 +2601,10 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
25952601 parseBracedList ();
25962602 }
25972603 break ;
2604+ case tok::comma:
2605+ SeenComma = true ;
2606+ nextToken ();
2607+ break ;
25982608 case tok::ellipsis:
25992609 MightBeFoldExpr = true ;
26002610 nextToken ();
0 commit comments