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

Douglas Gregor dgregor at apple.com
Mon Dec 19 12:51:17 PST 2011


Author: dgregor
Date: Mon Dec 19 14:51:16 2011
New Revision: 146903

URL: http://llvm.org/viewvc/llvm-project?rev=146903&view=rev
Log:
Remove ASTReader's PendingForwardRefs, which is now handled by the
(more general) fix-up of definition data pointers.

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=146903&r1=146902&r2=146903&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Dec 19 14:51:16 2011
@@ -328,16 +328,7 @@
   /// \brief Updates to the visible declarations of declaration contexts that
   /// haven't been loaded yet.
   DeclContextVisibleUpdatesPending PendingVisibleUpdates;
-
-  typedef SmallVector<Decl *, 4> ForwardRefs;
-  typedef llvm::DenseMap<const Decl *, ForwardRefs>
-      PendingForwardRefsMap;
   
-  /// \brief Forward references that have a definition but the definition decl
-  /// is still initializing. When the definition gets read it will update
-  /// the DefinitionData pointer of all pending references.
-  PendingForwardRefsMap PendingForwardRefs;
-
   /// \brief The set of C++ or Objective-C classes that have forward 
   /// declarations that have not yet been linked to their definitions.
   llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=146903&r1=146902&r2=146903&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Dec 19 14:51:16 2011
@@ -6149,9 +6149,6 @@
 
     finishPendingActions();
     PendingDeclChainsKnown.clear();
-
-    assert(PendingForwardRefs.size() == 0 &&
-           "Some forward refs did not get linked to the definition!");
   }
   --NumCurrentElementsDeserializing;
 }

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=146903&r1=146902&r2=146903&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Dec 19 14:51:16 2011
@@ -615,32 +615,10 @@
     // We will rebuild this list lazily.
     ID->setIvarList(0);
     
-    // If there are any pending forward references, make their definition data
-    // pointers point at the newly-allocated data.
-    ASTReader::PendingForwardRefsMap::iterator
-    FindI = Reader.PendingForwardRefs.find(ID);
-    if (FindI != Reader.PendingForwardRefs.end()) {
-      ASTReader::ForwardRefs &Refs = FindI->second;
-      for (ASTReader::ForwardRefs::iterator I = Refs.begin(), 
-                                            E = Refs.end(); 
-           I != E; ++I)
-        cast<ObjCInterfaceDecl>(*I)->Data = ID->Data;
-#ifndef NDEBUG
-      // We later check whether PendingForwardRefs is empty to make sure all
-      // pending references were linked.
-      Reader.PendingForwardRefs.erase(ID);
-#endif
-      
-      // Note that we have deserialized a definition.
-      Reader.PendingDefinitions.insert(ID);
-    }
-  } else if (Def) {
-    if (Def->Data) {
-      ID->Data = Def->Data;
-    } else {
-      // The definition is still initializing.
-      Reader.PendingForwardRefs[Def].push_back(ID);
-    }
+    // Note that we have deserialized a definition.
+    Reader.PendingDefinitions.insert(ID);
+  } else if (Def && Def->Data) {
+    ID->Data = Def->Data;
   }
 }
 
@@ -1018,31 +996,11 @@
   if (D == DefinitionDecl) {
     D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D);
     ReadCXXDefinitionData(*D->DefinitionData, Record, Idx);
-    // We read the definition info. Check if there are pending forward
-    // references that need to point to this DefinitionData pointer.
-    ASTReader::PendingForwardRefsMap::iterator
-        FindI = Reader.PendingForwardRefs.find(D);
-    if (FindI != Reader.PendingForwardRefs.end()) {
-      ASTReader::ForwardRefs &Refs = FindI->second;
-      for (ASTReader::ForwardRefs::iterator
-             I = Refs.begin(), E = Refs.end(); I != E; ++I)
-        cast<CXXRecordDecl>(*I)->DefinitionData = D->DefinitionData;
-#ifndef NDEBUG
-      // We later check whether PendingForwardRefs is empty to make sure all
-      // pending references were linked.
-      Reader.PendingForwardRefs.erase(D);
-#endif
-    }
-    
+
     // Note that we have deserialized a definition.
     Reader.PendingDefinitions.insert(D);
-  } else if (DefinitionDecl) {
-    if (DefinitionDecl->DefinitionData) {
-      D->DefinitionData = DefinitionDecl->DefinitionData;
-    } else {
-      // The definition is still initializing.
-      Reader.PendingForwardRefs[DefinitionDecl].push_back(D);
-    }
+  } else if (DefinitionDecl && DefinitionDecl->DefinitionData) {
+    D->DefinitionData = DefinitionDecl->DefinitionData;
   }
 }
 
@@ -2244,12 +2202,8 @@
       ObjCInterfaceDecl *ID = cast<ObjCInterfaceDecl>(D);
       ObjCInterfaceDecl *Def
         = Reader.ReadDeclAs<ObjCInterfaceDecl>(ModuleFile, Record, Idx);
-      if (Def->Data) {
+      if (Def->Data)
         ID->Data = Def->Data;
-      } else {
-        // The definition is still initializing.
-        Reader.PendingForwardRefs[Def].push_back(ID);
-      }
       break;
     }
     }





More information about the cfe-commits mailing list