File tree Expand file tree Collapse file tree 15 files changed +141
-0
lines changed Expand file tree Collapse file tree 15 files changed +141
-0
lines changed Original file line number Diff line number Diff line change @@ -682,6 +682,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
682682 // / For performance, track whether any function effects are in use.
683683 mutable bool AnyFunctionEffects = false ;
684684
685+ bool ExternalCopyConstructorsForExceptionObjectsLoaded = false ;
686+
685687 const TargetInfo *Target = nullptr ;
686688 const TargetInfo *AuxTarget = nullptr ;
687689 clang::PrintingPolicy PrintingPolicy;
@@ -3362,6 +3364,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
33623364 const FunctionDecl *FD,
33633365 llvm::function_ref<void (FunctionDecl *)> Pred) const ;
33643366
3367+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> *
3368+ getRecordToCopyCtor ();
3369+
33653370 const CXXConstructorDecl *
33663371 getCopyConstructorForExceptionObject (CXXRecordDecl *RD);
33673372
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ class ASTConsumer;
4040class ASTContext ;
4141class ASTSourceDescriptor ;
4242class CXXBaseSpecifier ;
43+ class CXXConstructorDecl ;
4344class CXXCtorInitializer ;
4445class CXXRecordDecl ;
4546class DeclarationName ;
@@ -175,6 +176,9 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
175176 LoadExternalSpecializations (const Decl *D,
176177 ArrayRef<TemplateArgument> TemplateArgs);
177178
179+ virtual void LoadExternalExceptionCopyingConstructors (
180+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> &RecordToCtor);
181+
178182 // / Ensures that the table of all visible declarations inside this
179183 // / context is up to date.
180184 // /
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
106106 LoadExternalSpecializations (const Decl *D,
107107 ArrayRef<TemplateArgument> TemplateArgs) override ;
108108
109+ void LoadExternalExceptionCopyingConstructors (
110+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> &RecordToCtor)
111+ override ;
112+
109113 // / Ensures that the table of all visible declarations inside this
110114 // / context is up to date.
111115 void completeVisibleDeclsMap (const DeclContext *DC) override ;
Original file line number Diff line number Diff line change @@ -742,6 +742,8 @@ enum ASTRecordTypes {
742742 UPDATE_MODULE_LOCAL_VISIBLE = 76 ,
743743
744744 UPDATE_TU_LOCAL_VISIBLE = 77 ,
745+
746+ MSCXXABI_EXCEPTION_COPYING_CONSTRUCTORS = 78 ,
745747};
746748
747749// / Record types used within a source manager block.
Original file line number Diff line number Diff line change @@ -1055,6 +1055,12 @@ class ASTReader
10551055 // / The IDs of all decls with function effects to be checked.
10561056 SmallVector<GlobalDeclID> DeclsWithEffectsToVerify;
10571057
1058+ struct RecordAndCopyingCtor {
1059+ GlobalDeclID RecordID;
1060+ GlobalDeclID CtorID;
1061+ };
1062+ SmallVector<RecordAndCopyingCtor> RecordToCopyingCtor;
1063+
10581064private:
10591065 struct ImportedSubmodule {
10601066 serialization::SubmoduleID ID;
@@ -2177,6 +2183,10 @@ class ASTReader
21772183 LoadExternalSpecializations (const Decl *D,
21782184 ArrayRef<TemplateArgument> TemplateArgs) override ;
21792185
2186+ void LoadExternalExceptionCopyingConstructors (
2187+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> &RecordToCtor)
2188+ override ;
2189+
21802190 // / Finds all the visible declarations with a given name.
21812191 // / The current implementation of this method just loads the entire
21822192 // / lookup table as unmaterialized references.
Original file line number Diff line number Diff line change @@ -13333,8 +13333,25 @@ ASTContext::createMangleNumberingContext() const {
1333313333 return ABI->createMangleNumberingContext();
1333413334}
1333513335
13336+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> *
13337+ ASTContext::getRecordToCopyCtor() {
13338+ if (ABI) { // TODO Why can this be null?
13339+ return ABI->getRecordToCopyCtor();
13340+ }
13341+ return nullptr;
13342+ }
13343+
1333613344const CXXConstructorDecl *
1333713345ASTContext::getCopyConstructorForExceptionObject(CXXRecordDecl *RD) {
13346+ if (!getTargetInfo().getCXXABI().isMicrosoft()) {
13347+ return nullptr;
13348+ }
13349+ if (ExternalSource && !ExternalCopyConstructorsForExceptionObjectsLoaded) {
13350+ auto *Map = ABI->getRecordToCopyCtor();
13351+ assert(Map);
13352+ ExternalSource->LoadExternalExceptionCopyingConstructors(*Map);
13353+ ExternalCopyConstructorsForExceptionObjectsLoaded = true;
13354+ }
1333813355 return ABI->getCopyConstructorForExceptionObject(
1333913356 cast<CXXRecordDecl>(RD->getFirstDecl()));
1334013357}
Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ class CXXABI {
5656 virtual void addCopyConstructorForExceptionObject (CXXRecordDecl *,
5757 CXXConstructorDecl *) = 0;
5858
59+ virtual llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> *
60+ getRecordToCopyCtor () = 0 ;
61+
5962 // / Retrieves the mapping from class to copy constructor for this C++ ABI.
6063 virtual const CXXConstructorDecl *
6164 getCopyConstructorForExceptionObject (CXXRecordDecl *) = 0 ;
Original file line number Diff line number Diff line change @@ -109,6 +109,9 @@ bool ExternalASTSource::LoadExternalSpecializations(
109109 return false ;
110110}
111111
112+ void ExternalASTSource::LoadExternalExceptionCopyingConstructors (
113+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> &) {}
114+
112115void ExternalASTSource::completeVisibleDeclsMap (const DeclContext *DC) {}
113116
114117void ExternalASTSource::FindExternalLexicalDecls (
Original file line number Diff line number Diff line change @@ -256,6 +256,11 @@ class ItaniumCXXABI : public CXXABI {
256256 return Layout.getNonVirtualSize () == PointerSize;
257257 }
258258
259+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> *
260+ getRecordToCopyCtor () override {
261+ return nullptr ;
262+ }
263+
259264 const CXXConstructorDecl *
260265 getCopyConstructorForExceptionObject (CXXRecordDecl *RD) override {
261266 return nullptr ;
Original file line number Diff line number Diff line change @@ -146,6 +146,11 @@ class MicrosoftCXXABI : public CXXABI {
146146 llvm_unreachable (" unapplicable to the MS ABI" );
147147 }
148148
149+ llvm::SmallDenseMap<CXXRecordDecl *, CXXConstructorDecl *> *
150+ getRecordToCopyCtor () override {
151+ return &RecordToCopyCtor;
152+ }
153+
149154 const CXXConstructorDecl *
150155 getCopyConstructorForExceptionObject (CXXRecordDecl *RD) override {
151156 return RecordToCopyCtor[RD];
You can’t perform that action at this time.
0 commit comments