clang
9.0.0svn
|
ExternalASTSource implementation that merges information from several ASTContexts. More...
#include "clang/AST/ExternalASTMerger.h"
Classes | |
struct | DCOrigin |
A single origin for a DeclContext. More... | |
struct | ImporterSource |
A source for an ExternalASTMerger. More... | |
struct | ImporterTarget |
The target for an ExternalASTMerger. More... | |
Public Types | |
typedef std::map< const DeclContext *, DCOrigin > | OriginMap |
typedef std::vector< std::unique_ptr< ASTImporter > > | ImporterVector |
![]() | |
enum | ExtKind { EK_Always, EK_Never, EK_ReplyHazy } |
Public Member Functions | |
ExternalASTMerger (const ImporterTarget &Target, llvm::ArrayRef< ImporterSource > Sources) | |
void | AddSources (llvm::ArrayRef< ImporterSource > Sources) |
Add a set of ASTContexts as possible origins. More... | |
void | RemoveSources (llvm::ArrayRef< ImporterSource > Sources) |
Remove a set of ASTContexts as possible origins. More... | |
bool | FindExternalVisibleDeclsByName (const DeclContext *DC, DeclarationName Name) override |
Implementation of the ExternalASTSource API. More... | |
void | FindExternalLexicalDecls (const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl *> &Result) override |
Implementation of the ExternalASTSource API. More... | |
void | CompleteType (TagDecl *Tag) override |
Implementation of the ExternalASTSource API. More... | |
void | CompleteType (ObjCInterfaceDecl *Interface) override |
Implementation of the ExternalASTSource API. More... | |
bool | CanComplete (DeclContext *DC) |
Returns true if DC can be found in any source AST context. More... | |
void | MaybeRecordOrigin (const DeclContext *ToDC, DCOrigin Origin) |
Records an origin in Origins only if name lookup would find something different or nothing at all. More... | |
void | ForceRecordOrigin (const DeclContext *ToDC, DCOrigin Origin) |
Regardless of any checks, override the Origin for a DeclContext. More... | |
const OriginMap & | GetOrigins () |
Get a read-only view of the Origins map, for use in constructing an ImporterSource for another ExternalASTMerger. More... | |
bool | HasImporterForOrigin (ASTContext &OriginContext) |
Returns true if Importers contains an ASTImporter whose source is OriginContext. More... | |
ASTImporter & | ImporterForOrigin (ASTContext &OriginContext) |
Returns a reference to the ASTRImporter from Importers whose origin is OriginContext. More... | |
void | SetLogStream (llvm::raw_string_ostream &Stream) |
Sets the current log stream. More... | |
llvm::raw_ostream & | logs () |
Log something if there is a logging callback installed. More... | |
bool | LoggingEnabled () |
True if the log stream is not llvm::nulls();. More... | |
![]() | |
ExternalASTSource ()=default | |
virtual | ~ExternalASTSource () |
uint32_t | getGeneration () const |
Get the current generation of this AST source. More... | |
virtual Decl * | GetExternalDecl (uint32_t ID) |
Resolve a declaration ID into a declaration, potentially building a new declaration. More... | |
virtual Selector | GetExternalSelector (uint32_t ID) |
Resolve a selector ID into a selector. More... | |
virtual uint32_t | GetNumExternalSelectors () |
Returns the number of selectors known to the external AST source. More... | |
virtual Stmt * | GetExternalDeclStmt (uint64_t Offset) |
Resolve the offset of a statement in the decl stream into a statement. More... | |
virtual CXXCtorInitializer ** | GetExternalCXXCtorInitializers (uint64_t Offset) |
Resolve the offset of a set of C++ constructor initializers in the decl stream into an array of initializers. More... | |
virtual CXXBaseSpecifier * | GetExternalCXXBaseSpecifiers (uint64_t Offset) |
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers. More... | |
virtual void | updateOutOfDateIdentifier (IdentifierInfo &II) |
Update an out-of-date identifier. More... | |
virtual void | completeVisibleDeclsMap (const DeclContext *DC) |
Ensures that the table of all visible declarations inside this context is up to date. More... | |
virtual Module * | getModule (unsigned ID) |
Retrieve the module that corresponds to the given module ID. More... | |
virtual bool | DeclIsFromPCHWithObjectFile (const Decl *D) |
Determine whether D comes from a PCH which was built with a corresponding object file. More... | |
virtual llvm::Optional< ASTSourceDescriptor > | getSourceDescriptor (unsigned ID) |
Return a descriptor for the corresponding module, if one exists. More... | |
virtual ExtKind | hasExternalDefinitions (const Decl *D) |
void | FindExternalLexicalDecls (const DeclContext *DC, SmallVectorImpl< Decl *> &Result) |
Finds all declarations lexically contained within the given DeclContext. More... | |
virtual void | FindFileRegionDecls (FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl *> &Decls) |
Get the decls that are contained in a file in the Offset/Length range. More... | |
virtual void | CompleteRedeclChain (const Decl *D) |
Gives the external AST source an opportunity to complete the redeclaration chain for a declaration. More... | |
virtual void | ReadComments () |
Loads comment ranges. More... | |
virtual void | StartedDeserializing () |
Notify ExternalASTSource that we started deserialization of a decl or type so until FinishedDeserializing is called there may be decls that are initializing. More... | |
virtual void | FinishedDeserializing () |
Notify ExternalASTSource that we finished the deserialization of a decl or type. More... | |
virtual void | StartTranslationUnit (ASTConsumer *Consumer) |
Function that will be invoked when we begin parsing a new translation unit involving this external AST source. More... | |
virtual void | PrintStats () |
Print any statistics that have been gathered regarding the external AST source. More... | |
virtual bool | layoutRecordType (const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &BaseOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &VirtualBaseOffsets) |
Perform layout on the given record. More... | |
MemoryBufferSizes | getMemoryBufferSizes () const |
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory. More... | |
virtual void | getMemoryBufferSizes (MemoryBufferSizes &sizes) const |
Additional Inherited Members | |
![]() | |
uint32_t | incrementGeneration (ASTContext &C) |
Increment the current generation. More... | |
![]() | |
static DeclContextLookupResult | SetExternalVisibleDeclsForName (const DeclContext *DC, DeclarationName Name, ArrayRef< NamedDecl *> Decls) |
static DeclContextLookupResult | SetNoExternalVisibleDeclsForName (const DeclContext *DC, DeclarationName Name) |
ExternalASTSource implementation that merges information from several ASTContexts.
ExtermalASTMerger maintains a vector of ASTImporters that it uses to import (potentially incomplete) Decls and DeclContexts from the source ASTContexts in response to ExternalASTSource API calls.
When lookup occurs in the resulting imported DeclContexts, the original DeclContexts need to be queried. Roughly, there are three cases here:
ExternalASTMerger's job is to maintain the data structures necessary to allow this. The data structures themselves can be extracted (read-only) and copied for re-use.
Definition at line 47 of file ExternalASTMerger.h.
typedef std::vector<std::unique_ptr<ASTImporter> > clang::ExternalASTMerger::ImporterVector |
Definition at line 57 of file ExternalASTMerger.h.
typedef std::map<const DeclContext *, DCOrigin> clang::ExternalASTMerger::OriginMap |
Definition at line 56 of file ExternalASTMerger.h.
ExternalASTMerger::ExternalASTMerger | ( | const ImporterTarget & | Target, |
llvm::ArrayRef< ImporterSource > | Sources | ||
) |
Definition at line 311 of file ExternalASTMerger.cpp.
References AddSources().
void ExternalASTMerger::AddSources | ( | llvm::ArrayRef< ImporterSource > | Sources | ) |
Add a set of ASTContexts as possible origins.
Usually the set will be initialized in the constructor, but long-lived ExternalASTMergers may need to import from new sources (for example, newly-parsed source files).
Ensures that Importers does not gain duplicate entries as a result.
Definition at line 316 of file ExternalASTMerger.cpp.
Referenced by ExternalASTMerger().
bool ExternalASTMerger::CanComplete | ( | DeclContext * | DC | ) |
Returns true if DC can be found in any source AST context.
Definition at line 258 of file ExternalASTMerger.cpp.
References clang::DeclContext::hasExternalLexicalStorage(), and clang::DeclContext::hasExternalVisibleStorage().
|
overridevirtual |
Implementation of the ExternalASTSource API.
Reimplemented from clang::ExternalASTSource.
Definition at line 222 of file ExternalASTMerger.cpp.
References clang::ExternalASTSource::CompleteType(), clang::Error, clang::Decl::getASTContext(), clang::ASTContext::getExternalSource(), clang::DeclContext::hasExternalLexicalStorage(), clang::ASTImporter::ImportDefinition_New(), clang::ASTImporter::MapImported(), and clang::TagDecl::setCompleteDefinition().
|
overridevirtual |
Implementation of the ExternalASTSource API.
Reimplemented from clang::ExternalASTSource.
Definition at line 239 of file ExternalASTMerger.cpp.
References clang::ExternalASTSource::CompleteType(), clang::Error, clang::Decl::getASTContext(), clang::ASTContext::getExternalSource(), clang::DeclContext::hasExternalLexicalStorage(), clang::ASTImporter::ImportDefinition_New(), and clang::ASTImporter::MapImported().
|
overridevirtual |
Implementation of the ExternalASTSource API.
Reimplemented from clang::ExternalASTSource.
Definition at line 419 of file ExternalASTMerger.cpp.
References clang::Decl::getDeclContext(), and clang::ASTImporter::Import().
|
overridevirtual |
Implementation of the ExternalASTSource API.
Reimplemented from clang::ExternalASTSource.
Definition at line 377 of file ExternalASTMerger.cpp.
References clang::C, clang::ASTImporter::Import(), importSpecializationsIfNeeded(), clang::Result, and clang::ExternalASTSource::SetExternalVisibleDeclsForName().
void ExternalASTMerger::ForceRecordOrigin | ( | const DeclContext * | ToDC, |
DCOrigin | Origin | ||
) |
Regardless of any checks, override the Origin for a DeclContext.
Definition at line 300 of file ExternalASTMerger.cpp.
References clang::ExternalASTMerger::DCOrigin::AST, and clang::ExternalASTMerger::DCOrigin::DC.
|
inline |
Get a read-only view of the Origins map, for use in constructing an ImporterSource for another ExternalASTMerger.
Definition at line 142 of file ExternalASTMerger.h.
References HasImporterForOrigin(), and ImporterForOrigin().
bool ExternalASTMerger::HasImporterForOrigin | ( | ASTContext & | OriginContext | ) |
Returns true if Importers contains an ASTImporter whose source is OriginContext.
Definition at line 186 of file ExternalASTMerger.cpp.
Referenced by GetOrigins().
ASTImporter & ExternalASTMerger::ImporterForOrigin | ( | ASTContext & | OriginContext | ) |
Returns a reference to the ASTRImporter from Importers whose origin is OriginContext.
This allows manual import of ASTs while preserving the OriginMap correctly.
Definition at line 171 of file ExternalASTMerger.cpp.
References ImporterForOrigin().
Referenced by GetOrigins(), and ImporterForOrigin().
|
inline |
True if the log stream is not llvm::nulls();.
Definition at line 170 of file ExternalASTMerger.h.
Referenced by RemoveSources().
|
inline |
Log something if there is a logging callback installed.
Definition at line 167 of file ExternalASTMerger.h.
void ExternalASTMerger::MaybeRecordOrigin | ( | const DeclContext * | ToDC, |
DCOrigin | Origin | ||
) |
Records an origin in Origins only if name lookup would find something different or nothing at all.
Definition at line 283 of file ExternalASTMerger.cpp.
References clang::ExternalASTMerger::DCOrigin::AST, clang::ExternalASTMerger::DCOrigin::DC, and clang::ASTContext::getTranslationUnitDecl().
void ExternalASTMerger::RemoveSources | ( | llvm::ArrayRef< ImporterSource > | Sources | ) |
Remove a set of ASTContexts as possible origins.
Sometimes an origin goes away (for example, if a source file gets superseded by a newer version).
The caller is responsible for ensuring that this doesn't leave DeclContexts that can't be completed.
Definition at line 324 of file ExternalASTMerger.cpp.
References LoggingEnabled().
|
inline |
Sets the current log stream.
Definition at line 154 of file ExternalASTMerger.h.