summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-04-30 02:24:17 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-04-30 02:24:17 +0000
commitd1c46746037cc1eb0cd28fb1581af7d262527f85 (patch)
treebe90feb128b08298d3489d835c30dfcbaa10d611 /clang/lib/Serialization/ASTReader.cpp
parentb5b622a03c5136fa10d245dbe1f8f278ebd98d1b (diff)
downloadbcm5719-llvm-d1c46746037cc1eb0cd28fb1581af7d262527f85.tar.gz
bcm5719-llvm-d1c46746037cc1eb0cd28fb1581af7d262527f85.zip
Defer loading any pending update records until we've finished deserializing.
This fixes a bug where an update record causes us to load an entity that refers to an entity we've not finished loading yet, resulting in badness. llvm-svn: 207603
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp28
1 files changed, 10 insertions, 18 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index ccdf3fe10ae..31b649f16e1 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3430,6 +3430,9 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
llvm::SaveAndRestore<SourceLocation>
SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
+ // Defer any pending actions until we get to the end of reading the AST file.
+ Deserializing AnASTFile(this);
+
// Bump the generation number.
unsigned PreviousGeneration = CurrentGeneration++;
@@ -3742,24 +3745,6 @@ void ASTReader::InitializeContext() {
DeserializationListener->DeclRead(PREDEF_DECL_TRANSLATION_UNIT_ID,
Context.getTranslationUnitDecl());
- // For any declarations we have already loaded, load any update records.
- {
- // We're not back to a consistent state until all our pending update
- // records have been loaded. There can be interdependencies between them.
- Deserializing SomeUpdateRecords(this);
- ReadingKindTracker ReadingKind(Read_Decl, *this);
-
- // Make sure we load the declaration update records for the translation
- // unit, if there are any.
- // FIXME: Is this necessary any more?
- loadDeclUpdateRecords(PREDEF_DECL_TRANSLATION_UNIT_ID,
- Context.getTranslationUnitDecl());
-
- for (auto &Update : PendingUpdateRecords)
- loadDeclUpdateRecords(Update.first, Update.second);
- PendingUpdateRecords.clear();
- }
-
// FIXME: Find a better way to deal with collisions between these
// built-in types. Right now, we just ignore the problem.
@@ -8057,6 +8042,13 @@ void ASTReader::finishPendingActions() {
Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
}
+ // Perform any pending declaration updates.
+ while (!PendingUpdateRecords.empty()) {
+ auto Update = PendingUpdateRecords.pop_back_val();
+ ReadingKindTracker ReadingKind(Read_Decl, *this);
+ loadDeclUpdateRecords(Update.first, Update.second);
+ }
+
// Trigger the import of the full definition of each class that had any
// odr-merging problems, so we can produce better diagnostics for them.
for (auto &Merge : PendingOdrMergeFailures) {
OpenPOWER on IntegriCloud