From 7640b02a561fd2b2c58a227b262b0c1ba93622ae Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 16 Feb 2013 00:48:59 +0000 Subject: [PCH] Deserializing the DeclContext of a template parameter is not safe until recursive loading is finished. Otherwise we may end up with a template trying to deserialize a template parameter that is in the process of getting loaded. rdar://13135282 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175329 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Serialization/ASTReader.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/clang/Serialization') diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index ecb550e26b..69a012cd17 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -833,6 +833,21 @@ private: /// \brief Keeps track of the elements added to PendingDeclChains. llvm::SmallSet PendingDeclChainsKnown; + /// \brief The Decl IDs for the Sema/Lexical DeclContext of a Decl that has + /// been loaded but its DeclContext was not set yet. + struct PendingDeclContextInfo { + Decl *D; + serialization::GlobalDeclID SemaDC; + serialization::GlobalDeclID LexicalDC; + }; + + /// \brief The set of Decls that have been loaded but their DeclContexts are + /// not set yet. + /// + /// The DeclContexts for these Decls will be set once recursive loading has + /// been completed. + std::deque PendingDeclContextInfos; + /// \brief The set of Objective-C categories that have been deserialized /// since the last time the declaration chains were linked. llvm::SmallPtrSet CategoriesDeserialized; @@ -1076,6 +1091,14 @@ private: void finishPendingActions(); + void addPendingDeclContextInfo(Decl *D, + serialization::GlobalDeclID SemaDC, + serialization::GlobalDeclID LexicalDC) { + assert(D); + PendingDeclContextInfo Info = { D, SemaDC, LexicalDC }; + PendingDeclContextInfos.push_back(Info); + } + /// \brief Produce an error diagnostic and return true. /// /// This routine should only be used for fatal errors that have to -- cgit v1.2.3-18-g5258