Index: clang/include/clang/Parse/Parser.h =================================================================== --- clang/include/clang/Parse/Parser.h +++ clang/include/clang/Parse/Parser.h @@ -1839,7 +1839,6 @@ /// ParseExpressionList - Used for C/C++ (argument-)expression-list. bool ParseExpressionList(SmallVectorImpl &Exprs, - SmallVectorImpl &CommaLocs, llvm::function_ref ExpressionStarts = llvm::function_ref(), bool FailImmediatelyOnInvalidExpr = false, @@ -1847,9 +1846,7 @@ /// ParseSimpleExpressionList - A simple comma-separated list of expressions, /// used for misc language extensions. - bool ParseSimpleExpressionList(SmallVectorImpl &Exprs, - SmallVectorImpl &CommaLocs); - + bool ParseSimpleExpressionList(SmallVectorImpl &Exprs); /// ParenParseOption - Control what ParseParenExpression will parse. enum ParenParseOption { Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -449,10 +449,8 @@ ? Sema::ExpressionEvaluationContext::Unevaluated : Sema::ExpressionEvaluationContext::ConstantEvaluated); - CommaLocsTy CommaLocs; ExprVector ParsedExprs; - if (ParseExpressionList(ParsedExprs, CommaLocs, - llvm::function_ref(), + if (ParseExpressionList(ParsedExprs, llvm::function_ref(), /*FailImmediatelyOnInvalidExpr=*/true, /*EarlyTypoCorrection=*/true)) { SkipUntil(tok::r_paren, StopAtSemi); @@ -2499,7 +2497,6 @@ T.consumeOpen(); ExprVector Exprs; - CommaLocsTy CommaLocs; InitializerScopeRAII InitScope(*this, D, ThisDecl); @@ -2524,7 +2521,7 @@ // ProduceConstructorSignatureHelp only on VarDecls. ExpressionStarts = SetPreferredType; } - if (ParseExpressionList(Exprs, CommaLocs, ExpressionStarts)) { + if (ParseExpressionList(Exprs, ExpressionStarts)) { if (ThisVarDecl && PP.isCodeCompletionReached() && !CalledSignatureHelp) { Actions.ProduceConstructorSignatureHelp( ThisVarDecl->getType()->getCanonicalTypeInternal(), @@ -2537,10 +2534,6 @@ } else { // Match the ')'. T.consumeClose(); - - assert(!Exprs.empty() && Exprs.size()-1 == CommaLocs.size() && - "Unexpected number of commas!"); - InitScope.pop(); ExprResult Initializer = Actions.ActOnParenListExpr(T.getOpenLocation(), Index: clang/lib/Parse/ParseDeclCXX.cpp =================================================================== --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -3803,7 +3803,6 @@ // Parse the optional expression-list. ExprVector ArgExprs; - CommaLocsTy CommaLocs; auto RunSignatureHelp = [&] { if (TemplateTypeTy.isInvalid()) return QualType(); @@ -3813,8 +3812,7 @@ CalledSignatureHelp = true; return PreferredType; }; - if (Tok.isNot(tok::r_paren) && - ParseExpressionList(ArgExprs, CommaLocs, [&] { + if (Tok.isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] { PreferredType.enterFunctionArgument(Tok.getLocation(), RunSignatureHelp); })) { Index: clang/lib/Parse/ParseExpr.cpp =================================================================== --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -1961,14 +1961,10 @@ ArgExprs.push_back(Idx.get()); } } else if (Tok.isNot(tok::r_square)) { - CommaLocsTy CommaLocs; - if (ParseExpressionList(ArgExprs, CommaLocs)) { + if (ParseExpressionList(ArgExprs)) { LHS = Actions.CorrectDelayedTyposInExpr(LHS); HasError = true; } - assert( - (ArgExprs.empty() || ArgExprs.size() == CommaLocs.size() + 1) && - "Unexpected number of commas!"); } } @@ -2030,10 +2026,9 @@ if (OpKind == tok::lesslessless) { ExprVector ExecConfigExprs; - CommaLocsTy ExecConfigCommaLocs; SourceLocation OpenLoc = ConsumeToken(); - if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) { + if (ParseSimpleExpressionList(ExecConfigExprs)) { (void)Actions.CorrectDelayedTyposInExpr(LHS); LHS = ExprError(); } @@ -2073,7 +2068,6 @@ } ExprVector ArgExprs; - CommaLocsTy CommaLocs; auto RunSignatureHelp = [&]() -> QualType { QualType PreferredType = Actions.ProduceCallSignatureHelp( LHS.get(), ArgExprs, PT.getOpenLocation()); @@ -2082,7 +2076,7 @@ }; if (OpKind == tok::l_paren || !LHS.isInvalid()) { if (Tok.isNot(tok::r_paren)) { - if (ParseExpressionList(ArgExprs, CommaLocs, [&] { + if (ParseExpressionList(ArgExprs, [&] { PreferredType.enterFunctionArgument(Tok.getLocation(), RunSignatureHelp); })) { @@ -2120,9 +2114,6 @@ PT.consumeClose(); LHS = ExprError(); } else { - assert( - (ArgExprs.size() == 0 || ArgExprs.size() - 1 == CommaLocs.size()) && - "Unexpected number of commas!"); Expr *Fn = LHS.get(); SourceLocation RParLoc = Tok.getLocation(); LHS = Actions.ActOnCallExpr(getCurScope(), Fn, Loc, ArgExprs, RParLoc, @@ -3126,11 +3117,9 @@ } else if (isTypeCast) { // Parse the expression-list. InMessageExpressionRAIIObject InMessage(*this, false); - ExprVector ArgExprs; - CommaLocsTy CommaLocs; - if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) { + if (!ParseSimpleExpressionList(ArgExprs)) { // FIXME: If we ever support comma expressions as operands to // fold-expressions, we'll need to allow multiple ArgExprs here. if (ExprType >= FoldExpr && ArgExprs.size() == 1 && @@ -3429,7 +3418,6 @@ /// [C++0x] braced-init-list /// \endverbatim bool Parser::ParseExpressionList(SmallVectorImpl &Exprs, - SmallVectorImpl &CommaLocs, llvm::function_ref ExpressionStarts, bool FailImmediatelyOnInvalidExpr, bool EarlyTypoCorrection) { @@ -3473,8 +3461,7 @@ break; // Move to the next argument, remember where the comma was. Token Comma = Tok; - CommaLocs.push_back(ConsumeToken()); - + ConsumeToken(); checkPotentialAngleBracketDelimiter(Comma); } if (SawError) { @@ -3496,9 +3483,7 @@ /// assignment-expression /// simple-expression-list , assignment-expression /// \endverbatim -bool -Parser::ParseSimpleExpressionList(SmallVectorImpl &Exprs, - SmallVectorImpl &CommaLocs) { +bool Parser::ParseSimpleExpressionList(SmallVectorImpl &Exprs) { while (true) { ExprResult Expr = ParseAssignmentExpression(); if (Expr.isInvalid()) @@ -3513,8 +3498,7 @@ // Move to the next argument, remember where the comma was. Token Comma = Tok; - CommaLocs.push_back(ConsumeToken()); - + ConsumeToken(); checkPotentialAngleBracketDelimiter(Comma); } } Index: clang/lib/Parse/ParseExprCXX.cpp =================================================================== --- clang/lib/Parse/ParseExprCXX.cpp +++ clang/lib/Parse/ParseExprCXX.cpp @@ -981,11 +981,10 @@ InitKind = LambdaCaptureInitKind::DirectInit; ExprVector Exprs; - CommaLocsTy Commas; if (Tentative) { Parens.skipToEnd(); *Tentative = LambdaIntroducerTentativeParse::Incomplete; - } else if (ParseExpressionList(Exprs, Commas)) { + } else if (ParseExpressionList(Exprs)) { Parens.skipToEnd(); Init = ExprError(); } else { @@ -1929,7 +1928,6 @@ PreferredType.enterTypeCast(Tok.getLocation(), TypeRep.get()); ExprVector Exprs; - CommaLocsTy CommaLocs; auto RunSignatureHelp = [&]() { QualType PreferredType; @@ -1942,7 +1940,7 @@ }; if (Tok.isNot(tok::r_paren)) { - if (ParseExpressionList(Exprs, CommaLocs, [&] { + if (ParseExpressionList(Exprs, [&] { PreferredType.enterFunctionArgument(Tok.getLocation(), RunSignatureHelp); })) { @@ -1960,8 +1958,6 @@ if (!TypeRep) return ExprError(); - assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&& - "Unexpected number of commas!"); return Actions.ActOnCXXTypeConstructExpr(TypeRep, T.getOpenLocation(), Exprs, T.getCloseLocation(), /*ListInitialization=*/false); @@ -3239,7 +3235,6 @@ T.consumeOpen(); ConstructorLParen = T.getOpenLocation(); if (Tok.isNot(tok::r_paren)) { - CommaLocsTy CommaLocs; auto RunSignatureHelp = [&]() { ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get(); @@ -3255,7 +3250,7 @@ CalledSignatureHelp = true; return PreferredType; }; - if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] { + if (ParseExpressionList(ConstructorArgs, [&] { PreferredType.enterFunctionArgument(Tok.getLocation(), RunSignatureHelp); })) { @@ -3354,9 +3349,7 @@ } // It's not a type, it has to be an expression list. - // Discard the comma locations - ActOnCXXNew has enough parameters. - CommaLocsTy CommaLocs; - return ParseExpressionList(PlacementArgs, CommaLocs); + return ParseExpressionList(PlacementArgs); } /// ParseCXXDeleteExpression - Parse a C++ delete-expression. Delete is used Index: clang/lib/Parse/ParseOpenMP.cpp =================================================================== --- clang/lib/Parse/ParseOpenMP.cpp +++ clang/lib/Parse/ParseOpenMP.cpp @@ -475,7 +475,6 @@ T.consumeOpen(); ExprVector Exprs; - CommaLocsTy CommaLocs; SourceLocation LParLoc = T.getOpenLocation(); auto RunSignatureHelp = [this, OmpPrivParm, LParLoc, &Exprs]() { @@ -485,7 +484,7 @@ CalledSignatureHelp = true; return PreferredType; }; - if (ParseExpressionList(Exprs, CommaLocs, [&] { + if (ParseExpressionList(Exprs, [&] { PreferredType.enterFunctionArgument(Tok.getLocation(), RunSignatureHelp); })) { @@ -499,9 +498,6 @@ if (!T.consumeClose()) RLoc = T.getCloseLocation(); - assert(!Exprs.empty() && Exprs.size() - 1 == CommaLocs.size() && - "Unexpected number of commas!"); - ExprResult Initializer = Actions.ActOnParenListExpr(T.getOpenLocation(), RLoc, Exprs); Actions.AddInitializerToDecl(OmpPrivParm, Initializer.get(),