[clang][NFC] Pass the ASTContext to CXXRecordDecl::setCaptures

In general Decl::getASTContext() is relatively expensive and here the changes
are non-invasive. NFC.
This commit is contained in:
Bruno Ricci 2020-07-28 15:49:05 +01:00
parent ad793ed903
commit 1ae63b4179
No known key found for this signature in database
GPG Key ID: D58C906B2F684D92
4 changed files with 9 additions and 7 deletions

View File

@ -1025,7 +1025,7 @@ public:
}
/// 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

View File

@ -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);

View File

@ -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.

View File

@ -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