diff options
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 4 |
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 |