[cfe-commits] r138496 - in /cfe/trunk: include/clang/AST/DeclBase.h include/clang/AST/ExternalASTSource.h include/clang/Serialization/ASTReader.h include/clang/Serialization/ChainedIncludesSource.h lib/AST/DeclBase.cpp lib/AST/ExternalASTSource.cpp lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp lib/Serialization/ChainedIncludesSource.cpp

Douglas Gregor dgregor at apple.com
Wed Aug 24 16:56:08 CDT 2011


Author: dgregor
Date: Wed Aug 24 16:56:08 2011
New Revision: 138496

URL: http://llvm.org/viewvc/llvm-project?rev=138496&view=rev
Log:
Don't force the complete deserialization of the visible-declarations
table when serializing an AST file. This was a holdover from the days
before chained PCH, and is a complete waste of time and storage
now. It's a good thing it's useless, because I have no idea how I
would have implemented MaterializeVisibleDecls efficiently in the
presence of modules.


Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/include/clang/AST/ExternalASTSource.h
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/include/clang/Serialization/ChainedIncludesSource.h
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/AST/ExternalASTSource.cpp
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTWriter.cpp
    cfe/trunk/lib/Serialization/ChainedIncludesSource.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Aug 24 16:56:08 2011
@@ -1276,14 +1276,6 @@
   /// the declaration chains.
   void makeDeclVisibleInContext(NamedDecl *D, bool Recoverable = true);
 
-  /// \brief Deserialize all the visible declarations from external storage.
-  ///
-  /// Name lookup deserializes visible declarations lazily, thus a DeclContext
-  /// may not have a complete name lookup table. This function deserializes
-  /// the rest of visible declarations from the external storage and completes
-  /// the name lookup table.
-  void MaterializeVisibleDeclsFromExternalStorage();
-
   /// udir_iterator - Iterates through the using-directives stored
   /// within this context.
   typedef UsingDirectiveDecl * const * udir_iterator;

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Wed Aug 24 16:56:08 2011
@@ -124,16 +124,6 @@
   virtual DeclContextLookupResult
   FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
 
-  /// \brief Deserialize all the visible declarations from external storage.
-  ///
-  /// Name lookup deserializes visible declarations lazily, thus a DeclContext
-  /// may not have a complete name lookup table. This function deserializes
-  /// the rest of visible declarations from the external storage and completes
-  /// the name lookup table of the DeclContext.
-  ///
-  /// The default implementation of this method is a no-op.
-  virtual void MaterializeVisibleDecls(const DeclContext *DC);
-
   /// \brief Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.
   ///
@@ -231,10 +221,6 @@
   static DeclContextLookupResult
   SetNoExternalVisibleDeclsForName(const DeclContext *DC,
                                    DeclarationName Name);
-
-  void MaterializeVisibleDeclsForName(const DeclContext *DC,
-                                      DeclarationName Name,
-                                 SmallVectorImpl<NamedDecl*> &Decls);
 };
 
 /// \brief A lazy pointer to an AST node (of base type T) that resides

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Aug 24 16:56:08 2011
@@ -1368,8 +1368,6 @@
   FindExternalVisibleDeclsByName(const DeclContext *DC,
                                  DeclarationName Name);
 
-  virtual void MaterializeVisibleDecls(const DeclContext *DC);
-
   /// \brief Read all of the declarations lexically stored in a
   /// declaration context.
   ///

Modified: cfe/trunk/include/clang/Serialization/ChainedIncludesSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ChainedIncludesSource.h?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ChainedIncludesSource.h (original)
+++ cfe/trunk/include/clang/Serialization/ChainedIncludesSource.h Wed Aug 24 16:56:08 2011
@@ -46,7 +46,6 @@
   virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
   virtual DeclContextLookupResult
   FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
-  virtual void MaterializeVisibleDecls(const DeclContext *DC);
   virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC,
                                         bool (*isKindWeWant)(Decl::Kind),
                                         SmallVectorImpl<Decl*> &Result);

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Aug 24 16:56:08 2011
@@ -910,25 +910,6 @@
   return List.getLookupResult();
 }
 
-void ExternalASTSource::MaterializeVisibleDeclsForName(const DeclContext *DC,
-                                                       DeclarationName Name,
-                                     SmallVectorImpl<NamedDecl*> &Decls) {
-  assert(DC->LookupPtr);
-  StoredDeclsMap &Map = *DC->LookupPtr;
-
-  // If there's an entry in the table the visible decls for this name have
-  // already been deserialized.
-  if (Map.find(Name) == Map.end()) {
-    StoredDeclsList &List = Map[Name];
-    for (unsigned I = 0, N = Decls.size(); I != N; ++I) {
-      if (List.isNull())
-        List.setOnlyValue(Decls[I]);
-      else
-        List.AddSubsequentDecl(Decls[I]);
-    }
-  }
-}
-
 DeclContext::decl_iterator DeclContext::noload_decls_begin() const {
   return decl_iterator(FirstDecl);
 }
@@ -1207,15 +1188,6 @@
   DeclNameEntries.AddSubsequentDecl(D);
 }
 
-void DeclContext::MaterializeVisibleDeclsFromExternalStorage() {
-  ExternalASTSource *Source = getParentASTContext().getExternalSource();
-  assert(hasExternalVisibleStorage() && Source && "No external storage?");
-
-  if (!LookupPtr)
-    CreateStoredDeclsMap(getParentASTContext());
-  Source->MaterializeVisibleDecls(this);
-}
-
 /// Returns iterator range [First, Last) of UsingDirectiveDecls stored within
 /// this context.
 DeclContext::udir_iterator_range

Modified: cfe/trunk/lib/AST/ExternalASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTSource.cpp?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExternalASTSource.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTSource.cpp Wed Aug 24 16:56:08 2011
@@ -49,8 +49,6 @@
   return DeclContext::lookup_result();
 }
 
-void ExternalASTSource::MaterializeVisibleDecls(const DeclContext *DC) { }
-
 ExternalLoadResult 
 ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
                                             bool (*isKindWeWant)(Decl::Kind),

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Aug 24 16:56:08 2011
@@ -4405,46 +4405,6 @@
   return const_cast<DeclContext*>(DC)->lookup(Name);
 }
 
-void ASTReader::MaterializeVisibleDecls(const DeclContext *DC) {
-  assert(DC->hasExternalVisibleStorage() &&
-         "DeclContext has no visible decls in storage");
-
-  SmallVector<NamedDecl *, 64> Decls;
-  // There might be visible decls in multiple parts of the chain, for the TU
-  // and namespaces.
-  // There might be lexical decls in multiple modules, for the TU at
-  // least.
-  // FIXME: We might want a faster way to zero
-  // FIXME: Going backwards through the chain does the right thing for
-  // chained PCH; for modules, it isn't clear what the right thing is.
-  for (ModuleReverseIterator M = ModuleMgr.rbegin(), MEnd = ModuleMgr.rend();
-       M != MEnd; ++M) {
-    Module::DeclContextInfosMap::iterator Info
-      = (*M)->DeclContextInfos.find(DC);
-    if (Info == (*M)->DeclContextInfos.end() || !Info->second.LexicalDecls)
-      continue;
-
-    if (!Info->second.NameLookupTableData)
-      continue;
-
-    ASTDeclContextNameLookupTable *LookupTable =
-        (ASTDeclContextNameLookupTable*)Info->second.NameLookupTableData;
-    for (ASTDeclContextNameLookupTable::item_iterator
-           ItemI = LookupTable->item_begin(),
-           ItemEnd = LookupTable->item_end() ; ItemI != ItemEnd; ++ItemI) {
-      ASTDeclContextNameLookupTable::item_iterator::value_type Val
-          = *ItemI;
-      ASTDeclContextNameLookupTrait::data_type Data = Val.second;
-      Decls.clear();
-      for (; Data.first != Data.second; ++Data.first) {
-        if (NamedDecl *ND = GetLocalDeclAs<NamedDecl>(**M, *Data.first))
-          Decls.push_back(ND);
-      }
-      MaterializeVisibleDeclsForName(DC, Val.first, Decls);
-    }
-  }
-}
-
 void ASTReader::PassInterestingDeclsToConsumer() {
   assert(Consumer);
   while (!InterestingDecls.empty()) {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Aug 24 16:56:08 2011
@@ -2608,9 +2608,7 @@
     return 0;
 
   // Force the DeclContext to build a its name-lookup table.
-  if (DC->hasExternalVisibleStorage())
-    DC->MaterializeVisibleDeclsFromExternalStorage();
-  else
+  if (!DC->hasExternalVisibleStorage())
     DC->lookup(DeclarationName());
 
   // Serialize the contents of the mapping used for lookup. Note that,

Modified: cfe/trunk/lib/Serialization/ChainedIncludesSource.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ChainedIncludesSource.cpp?rev=138496&r1=138495&r2=138496&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ChainedIncludesSource.cpp (original)
+++ cfe/trunk/lib/Serialization/ChainedIncludesSource.cpp Wed Aug 24 16:56:08 2011
@@ -190,9 +190,6 @@
                                                       DeclarationName Name) {
   return getFinalReader().FindExternalVisibleDeclsByName(DC, Name);
 }
-void ChainedIncludesSource::MaterializeVisibleDecls(const DeclContext *DC) {
-  return getFinalReader().MaterializeVisibleDecls(DC);
-}
 ExternalLoadResult 
 ChainedIncludesSource::FindExternalLexicalDecls(const DeclContext *DC,
                                       bool (*isKindWeWant)(Decl::Kind),




More information about the cfe-commits mailing list