[cfe-commits] r150153 - /cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Feb 8 22:02:44 PST 2012


Author: akirtzidis
Date: Thu Feb  9 00:02:44 2012
New Revision: 150153

URL: http://llvm.org/viewvc/llvm-project?rev=150153&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=150153&r1=150152&r2=150153&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Feb  9 00:02:44 2012
@@ -2018,6 +2018,10 @@
 
   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





More information about the cfe-commits mailing list