summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-24 21:56:08 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-24 21:56:08 +0000
commitc266de97e269c3747ffc2d122fe53185b541cb37 (patch)
tree70a14228156575261cd16cc68a5472d61e1d7700
parente94cb98d39fcd2cca68ab1b0d71f9a16b5e934c1 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138496 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclBase.h8
-rw-r--r--include/clang/AST/ExternalASTSource.h14
-rw-r--r--include/clang/Serialization/ASTReader.h2
-rw-r--r--include/clang/Serialization/ChainedIncludesSource.h1
-rw-r--r--lib/AST/DeclBase.cpp28
-rw-r--r--lib/AST/ExternalASTSource.cpp2
-rw-r--r--lib/Serialization/ASTReader.cpp40
-rw-r--r--lib/Serialization/ASTWriter.cpp4
-rw-r--r--lib/Serialization/ChainedIncludesSource.cpp3
9 files changed, 1 insertions, 101 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index b407701a7e..042c50f2a8 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -1276,14 +1276,6 @@ public:
/// 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;
diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h
index 6225057659..94b756773b 100644
--- a/include/clang/AST/ExternalASTSource.h
+++ b/include/clang/AST/ExternalASTSource.h
@@ -124,16 +124,6 @@ public:
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 @@ protected:
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
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index a3fe75205a..29bebcde28 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -1368,8 +1368,6 @@ public:
FindExternalVisibleDeclsByName(const DeclContext *DC,
DeclarationName Name);
- virtual void MaterializeVisibleDecls(const DeclContext *DC);
-
/// \brief Read all of the declarations lexically stored in a
/// declaration context.
///
diff --git a/include/clang/Serialization/ChainedIncludesSource.h b/include/clang/Serialization/ChainedIncludesSource.h
index 4626c7f8f2..620dbdf40c 100644
--- a/include/clang/Serialization/ChainedIncludesSource.h
+++ b/include/clang/Serialization/ChainedIncludesSource.h
@@ -46,7 +46,6 @@ protected:
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);
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index ca3f5b563c..d179f7bfea 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -910,25 +910,6 @@ ExternalASTSource::SetExternalVisibleDeclsForName(const DeclContext *DC,
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 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
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
diff --git a/lib/AST/ExternalASTSource.cpp b/lib/AST/ExternalASTSource.cpp
index 4d66bec5d1..fd616dbc9d 100644
--- a/lib/AST/ExternalASTSource.cpp
+++ b/lib/AST/ExternalASTSource.cpp
@@ -49,8 +49,6 @@ ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
return DeclContext::lookup_result();
}
-void ExternalASTSource::MaterializeVisibleDecls(const DeclContext *DC) { }
-
ExternalLoadResult
ExternalASTSource::FindExternalLexicalDecls(const DeclContext *DC,
bool (*isKindWeWant)(Decl::Kind),
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 0a2992baa5..cb1498e815 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -4405,46 +4405,6 @@ ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC,
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()) {
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index acd05006c3..79703216f5 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -2608,9 +2608,7 @@ uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context,
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,
diff --git a/lib/Serialization/ChainedIncludesSource.cpp b/lib/Serialization/ChainedIncludesSource.cpp
index 000e76846e..454e4194ab 100644
--- a/lib/Serialization/ChainedIncludesSource.cpp
+++ b/lib/Serialization/ChainedIncludesSource.cpp
@@ -190,9 +190,6 @@ ChainedIncludesSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
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),