mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 18:11:19 +00:00
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. llvm-svn: 138496
This commit is contained in:
parent
4b701af908
commit
a3e59b49e7
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
@ -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()) {
|
||||
|
@ -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,
|
||||
|
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user