From: Argyrios Kyrtzidis Date: Thu, 9 Feb 2012 06:02:44 +0000 (+0000) Subject: [PCH] Set the DeclContext before doing any deserialization, to make sure internal X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53a8b9789c8e87b67aa802e2df205db702c5ef27;p=clang [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 --- 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