diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp index c1dafe9..f8938ba 100644 --- a/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp +++ b/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp @@ -841,6 +841,7 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, // Parse capture. LambdaCaptureKind Kind = LCK_ByCopy; + LambdaCaptureInitKind InitKind = LambdaCaptureInitKind::NoInit; SourceLocation Loc; IdentifierInfo *Id = nullptr; SourceLocation EllipsisLoc; @@ -878,6 +879,8 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, BalancedDelimiterTracker Parens(*this, tok::l_paren); Parens.consumeOpen(); + InitKind = LambdaCaptureInitKind::DirectInit; + ExprVector Exprs; CommaLocsTy Commas; if (SkippedInits) { @@ -898,14 +901,13 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, // to save the necessary state, and restore it later. EnterExpressionEvaluationContext EC(Actions, Sema::PotentiallyEvaluated); - bool HadEquals = TryConsumeToken(tok::equal); + + if (TryConsumeToken(tok::equal)) + InitKind = LambdaCaptureInitKind::CopyInit; + else + InitKind = LambdaCaptureInitKind::ListInit; if (!SkippedInits) { - // Warn on constructs that will change meaning when we implement N3922 - if (!HadEquals && Tok.is(tok::l_brace)) { - Diag(Tok, diag::warn_init_capture_direct_list_init) - << FixItHint::CreateInsertion(Tok.getLocation(), "="); - } Init = ParseInitializer(); } else if (Tok.is(tok::l_brace)) { BalancedDelimiterTracker Braces(*this, tok::l_brace); @@ -993,19 +995,19 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, // If x was not const, the second use would require 'L' to capture, and // that would be an error. - ParsedType InitCaptureParsedType; + ParsedType InitCaptureType; if (Init.isUsable()) { // Get the pointer and store it in an lvalue, so we can use it as an // out argument. Expr *InitExpr = Init.get(); // This performs any lvalue-to-rvalue conversions if necessary, which // can affect what gets captured in the containing decl-context. - QualType InitCaptureType = Actions.performLambdaInitCaptureInitialization( - Loc, Kind == LCK_ByRef, Id, InitExpr); + InitCaptureType = Actions.actOnLambdaInitCaptureInitialization( + Loc, Kind == LCK_ByRef, Id, InitKind, InitExpr); Init = InitExpr; - InitCaptureParsedType.set(InitCaptureType); } - Intro.addCapture(Kind, Loc, Id, EllipsisLoc, Init, InitCaptureParsedType); + Intro.addCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init, + InitCaptureType); } T.consumeClose(); @@ -1149,7 +1151,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( /*VolatileQualifierLoc=*/NoLoc, /*RestrictQualifierLoc=*/NoLoc, MutableLoc, - ESpecType, ESpecRange.getBegin(), + ESpecType, ESpecRange, DynamicExceptions.data(), DynamicExceptionRanges.data(), DynamicExceptions.size(), @@ -1217,7 +1219,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( /*RestrictQualifierLoc=*/NoLoc, MutableLoc, EST_None, - /*ESpecLoc=*/NoLoc, + /*ESpecRange=*/SourceRange(), /*Exceptions=*/nullptr, /*ExceptionRanges=*/nullptr, /*NumExceptions=*/0, @@ -1558,6 +1560,21 @@ ExprResult Parser::ParseThrowExpression() { } } +/// \brief Parse the C++ Coroutines co_yield expression. +/// +/// co_yield-expression: +/// 'co_yield' assignment-expression[opt] +ExprResult Parser::ParseCoyieldExpression() { + assert(Tok.is(tok::kw_co_yield) && "Not co_yield!"); + + SourceLocation Loc = ConsumeToken(); + ExprResult Expr = Tok.is(tok::l_brace) ? ParseBraceInitializer() + : ParseAssignmentExpression(); + if (!Expr.isInvalid()) + Expr = Actions.ActOnCoyieldExpr(getCurScope(), Loc, Expr.get()); + return Expr; +} + /// ParseCXXThis - This handles the C++ 'this' pointer. /// /// C++ 9.3.2: In the body of a non-static member function, the keyword this is @@ -1805,7 +1822,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { DS.SetRangeEnd(Tok.getAnnotationEndLoc()); ConsumeToken(); - DS.Finish(Diags, PP, Policy); + DS.Finish(Actions, Policy); return; } @@ -1861,12 +1878,12 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { case tok::annot_decltype: case tok::kw_decltype: DS.SetRangeEnd(ParseDecltypeSpecifier(DS)); - return DS.Finish(Diags, PP, Policy); + return DS.Finish(Actions, Policy); // GNU typeof support. case tok::kw_typeof: ParseTypeofSpecifier(DS); - DS.Finish(Diags, PP, Policy); + DS.Finish(Actions, Policy); return; } if (Tok.is(tok::annot_typename)) @@ -1874,7 +1891,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { else DS.SetRangeEnd(Tok.getLocation()); ConsumeToken(); - DS.Finish(Diags, PP, Policy); + DS.Finish(Actions, Policy); } /// ParseCXXTypeSpecifierSeq - Parse a C++ type-specifier-seq (C++ @@ -1890,7 +1907,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { /// bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) { ParseSpecifierQualifierList(DS, AS_none, DSC_type_specifier); - DS.Finish(Diags, PP, Actions.getASTContext().getPrintingPolicy()); + DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy()); return false; } @@ -2289,7 +2306,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, // This isn't a valid literal-operator-id, but we think we know // what the user meant. Tell them what they should have written. SmallString<32> Str; - Str += "\"\" "; + Str += "\"\""; Str += II->getName(); Diag(DiagLoc, DiagId) << FixItHint::CreateReplacement( SourceRange(TokLocs.front(), TokLocs.back()), Str); |