Author: Bruno Ricci Date: 2020-07-29T14:55:15+01:00 New Revision: 1ae63b4179c222431cd6a4b2397abceaa5bc3d30
URL: https://github.com/llvm/llvm-project/commit/1ae63b4179c222431cd6a4b2397abceaa5bc3d30 DIFF: https://github.com/llvm/llvm-project/commit/1ae63b4179c222431cd6a4b2397abceaa5bc3d30.diff LOG: [clang][NFC] Pass the ASTContext to CXXRecordDecl::setCaptures In general Decl::getASTContext() is relatively expensive and here the changes are non-invasive. NFC. Added: Modified: clang/include/clang/AST/DeclCXX.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/DeclCXX.cpp clang/lib/Sema/SemaLambda.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 2b8d7e879a0a..20f058b87e7f 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<LambdaCapture> Captures); + void setCaptures(ASTContext &Context, ArrayRef<LambdaCapture> 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 e0bca8f08bb4..12dcd14c06bf 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<CXXRecordDecl>(To)->setCaptures(ToCaptures); + cast<CXXRecordDecl>(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 6f1fd2f14ede..59ae5cb300f7 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<LambdaCapture> Captures) { - ASTContext &Context = getASTContext(); +void CXXRecordDecl::setCaptures(ASTContext &Context, + ArrayRef<LambdaCapture> Captures) { CXXRecordDecl::LambdaDefinitionData &Data = getLambdaData(); // Copy captures. diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index dc74f6e2f7dc..c9f2854f7acc 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits