aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-09 06:02:44 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-02-09 06:02:44 +0000
commit53a8b9789c8e87b67aa802e2df205db702c5ef27 (patch)
tree5851642af04776aa198ec82f5c8813f6ff72c4ca
parentb9da55780eb66fb09e771dbc5ff01eec5c4d957b (diff)
[PCH] Set the DeclContext before doing any deserialization, to make sure internal
calls to Decl::getASTContext() by Decl's methods will find the TranslationUnitDecl without crashing due to a parent declaration context still deserializing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150153 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index 690c81ce53..e2f4ae3a9b 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -2018,6 +2018,10 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
assert(D && "Unknown declaration reading AST file");
LoadedDecl(Index, D);
+ // Set the DeclContext before doing any deserialization, to make sure internal
+ // calls to Decl::getASTContext() by Decl's methods will find the
+ // TranslationUnitDecl without crashing.
+ D->setDeclContext(Context.getTranslationUnitDecl());
Reader.Visit(D);
// If this declaration is also a declaration context, get the