aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-30 10:03:16 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-30 10:03:16 +0000
commit29ee3a273f58e16df7f2c524ab62a869e44fc9b1 (patch)
tree9113a442ca504710327186177decaccd36568d13 /lib/Frontend/PCHReader.cpp
parent207014eb2b372aa33721e86d90a8a586ba8dc8ae (diff)
Refactor the way PCHReader tracks whether we are in recursive loading.
-Replace CurrentlyLoadingTypeOrDecl with a counting scheme (NumCurrentElementsDeserializing) -Provide outside access to the mechanism by adding methods StartedDeserializing/FinishedDeserializing to ExternalASTSource. These are preparation for the next commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109856 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r--lib/Frontend/PCHReader.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 6fa7294f87..5a239e4f04 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -426,7 +426,7 @@ PCHReader::PCHReader(Preprocessor &PP, ASTContext *Context,
TotalNumStatements(0), NumMacrosRead(0), NumMethodPoolSelectorsRead(0),
NumMethodPoolMisses(0), TotalNumMacros(0), NumLexicalDeclContextsRead(0),
TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0),
- TotalVisibleDeclContexts(0), CurrentlyLoadingTypeOrDecl(0) {
+ TotalVisibleDeclContexts(0), NumCurrentElementsDeserializing(0) {
RelocatablePCH = false;
}
@@ -443,7 +443,7 @@ PCHReader::PCHReader(SourceManager &SourceMgr, FileManager &FileMgr,
TotalNumStatements(0), NumMacrosRead(0), NumMethodPoolSelectorsRead(0),
NumMethodPoolMisses(0), TotalNumMacros(0), NumLexicalDeclContextsRead(0),
TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0),
- TotalVisibleDeclContexts(0), CurrentlyLoadingTypeOrDecl(0) {
+ TotalVisibleDeclContexts(0), NumCurrentElementsDeserializing(0) {
RelocatablePCH = false;
}
@@ -2242,7 +2242,7 @@ QualType PCHReader::ReadTypeRecord(unsigned Index) {
ReadingKindTracker ReadingKind(Read_Type, *this);
// Note that we are loading a type record.
- LoadingTypeOrDecl Loading(*this);
+ Deserializing AType(this);
DeclsCursor.JumpToBit(Loc.second);
RecordData Record;
@@ -3235,7 +3235,7 @@ void
PCHReader::SetGloballyVisibleDecls(IdentifierInfo *II,
const llvm::SmallVectorImpl<uint32_t> &DeclIDs,
bool Nonrecursive) {
- if (CurrentlyLoadingTypeOrDecl && !Nonrecursive) {
+ if (NumCurrentElementsDeserializing && !Nonrecursive) {
PendingIdentifierInfos.push_back(PendingIdentifierInfo());
PendingIdentifierInfo &PII = PendingIdentifierInfos.back();
PII.II = II;
@@ -3677,28 +3677,22 @@ void PCHReader::SetLabelOf(AddrLabelExpr *S, unsigned ID) {
}
}
-
-PCHReader::LoadingTypeOrDecl::LoadingTypeOrDecl(PCHReader &Reader)
- : Reader(Reader), Parent(Reader.CurrentlyLoadingTypeOrDecl) {
- Reader.CurrentlyLoadingTypeOrDecl = this;
-}
-
-PCHReader::LoadingTypeOrDecl::~LoadingTypeOrDecl() {
- if (!Parent) {
+void PCHReader::FinishedDeserializing() {
+ assert(NumCurrentElementsDeserializing &&
+ "FinishedDeserializing not paired with StartedDeserializing");
+ if (NumCurrentElementsDeserializing == 1) {
// If any identifiers with corresponding top-level declarations have
// been loaded, load those declarations now.
- while (!Reader.PendingIdentifierInfos.empty()) {
- Reader.SetGloballyVisibleDecls(Reader.PendingIdentifierInfos.front().II,
- Reader.PendingIdentifierInfos.front().DeclIDs,
- true);
- Reader.PendingIdentifierInfos.pop_front();
+ while (!PendingIdentifierInfos.empty()) {
+ SetGloballyVisibleDecls(PendingIdentifierInfos.front().II,
+ PendingIdentifierInfos.front().DeclIDs, true);
+ PendingIdentifierInfos.pop_front();
}
// We are not in recursive loading, so it's safe to pass the "interesting"
// decls to the consumer.
- if (Reader.Consumer)
- Reader.PassInterestingDeclsToConsumer();
+ if (Consumer)
+ PassInterestingDeclsToConsumer();
}
-
- Reader.CurrentlyLoadingTypeOrDecl = Parent;
+ --NumCurrentElementsDeserializing;
}