[cfe-commits] r144524 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTReaderDecl.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Sun Nov 13 23:08:00 PST 2011


Author: akirtzidis
Date: Mon Nov 14 01:07:59 2011
New Revision: 144524

URL: http://llvm.org/viewvc/llvm-project?rev=144524&view=rev
Log:
[PCH] Load the chained objc categories only after recursive loading is finished
otherwise we may crash.

Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=144524&r1=144523&r2=144524&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Nov 14 01:07:59 2011
@@ -624,6 +624,11 @@
   /// deeply nested calls when there are many redeclarations.
   std::deque<std::pair<Decl *, serialization::DeclID> > PendingPreviousDecls;
 
+  /// \brief We delay loading the chain of objc categories after recursive
+  /// loading of declarations is finished.
+  std::vector<std::pair<ObjCInterfaceDecl *, serialization::DeclID> >
+    PendingChainedObjCCategories;
+
   /// \brief Ready to load the previous declaration of the given Decl.
   void loadAndAttachPreviousDecl(Decl *D, serialization::DeclID ID);
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=144524&r1=144523&r2=144524&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Nov 14 01:07:59 2011
@@ -5543,6 +5543,14 @@
       PendingPreviousDecls.pop_front();
     }
 
+    for (std::vector<std::pair<ObjCInterfaceDecl *,
+                               serialization::DeclID> >::iterator
+           I = PendingChainedObjCCategories.begin(),
+           E = PendingChainedObjCCategories.end(); I != E; ++I) {
+      loadObjCChainedCategories(I->second, I->first);
+    }
+    PendingChainedObjCCategories.clear();
+
     // We are not in recursive loading, so it's safe to pass the "interesting"
     // decls to the consumer.
     if (Consumer)

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=144524&r1=144523&r2=144524&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Nov 14 01:07:59 2011
@@ -1772,9 +1772,11 @@
 
   // Load any relevant update records.
   loadDeclUpdateRecords(ID, D);
-  
+
+  // Load the category chain after recursive loading is finished.
   if (ObjCChainedCategoriesInterfaces.count(ID))
-    loadObjCChainedCategories(ID, cast<ObjCInterfaceDecl>(D));
+    PendingChainedObjCCategories.push_back(
+                                std::make_pair(cast<ObjCInterfaceDecl>(D), ID));
   
   // If we have deserialized a declaration that has a definition the
   // AST consumer might need to know about, queue it.





More information about the cfe-commits mailing list