diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 2b8d7e879a0aad..20f058b87e7f33 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1025,7 +1025,7 @@ class CXXRecordDecl : public RecordDecl { } /// Set the captures for this lambda closure type. - void setCaptures(ArrayRef Captures); + void setCaptures(ASTContext &Context, ArrayRef Captures); /// For a closure type, retrieve the mapping from captured /// variables and \c this to the non-static data members that store the diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index e0bca8f08bb416..12dcd14c06bfab 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -1900,7 +1900,8 @@ Error ASTNodeImporter::ImportDefinition( else return ToCaptureOrErr.takeError(); } - cast(To)->setCaptures(ToCaptures); + cast(To)->setCaptures(Importer.getToContext(), + ToCaptures); } Error Result = ImportDeclContext(From, /*ForceImport=*/true); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 6f1fd2f14edeb5..59ae5cb300f727 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -1383,8 +1383,8 @@ void CXXRecordDecl::finishedDefaultedOrDeletedMember(CXXMethodDecl *D) { data().DeclaredNonTrivialSpecialMembers |= SMKind; } -void CXXRecordDecl::setCaptures(ArrayRef Captures) { - ASTContext &Context = getASTContext(); +void CXXRecordDecl::setCaptures(ASTContext &Context, + ArrayRef Captures) { CXXRecordDecl::LambdaDefinitionData &Data = getLambdaData(); // Copy captures. diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index dc74f6e2f7dc50..c9f2854f7accfd 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -1624,8 +1624,9 @@ FieldDecl *Sema::BuildCaptureField(RecordDecl *RD, // Build the non-static data member. FieldDecl *Field = - FieldDecl::Create(Context, RD, Loc, Loc, nullptr, FieldType, TSI, nullptr, - false, ICIS_NoInit); + FieldDecl::Create(Context, RD, /*StartLoc=*/Loc, /*IdLoc=*/Loc, + /*Id=*/nullptr, FieldType, TSI, /*BW=*/nullptr, + /*Mutable=*/false, ICIS_NoInit); // If the variable being captured has an invalid type, mark the class as // invalid as well. if (!FieldType->isDependentType()) { @@ -1785,7 +1786,7 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, CUDACheckLambdaCapture(CallOperator, From); } - Class->setCaptures(Captures); + Class->setCaptures(Context, Captures); // C++11 [expr.prim.lambda]p6: // The closure type for a lambda-expression with no lambda-capture