clang  6.0.0svn
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
clang::ExternalASTSource Class Reference

Abstract interface for external sources of AST nodes. More...

#include "clang/AST/ExternalASTSource.h"

Inheritance diagram for clang::ExternalASTSource:
Inheritance graph
[legend]
Collaboration diagram for clang::ExternalASTSource:
Collaboration graph
[legend]

Classes

class  ASTSourceDescriptor
 Abstracts clang modules and precompiled header files and holds everything needed to generate debug info for an imported module or PCH. More...
 
class  Deserializing
 RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing. More...
 
struct  MemoryBufferSizes
 

Public Types

enum  ExtKind { EK_Always, EK_Never, EK_ReplyHazy }
 

Public Member Functions

 ExternalASTSource ()=default
 
virtual ~ExternalASTSource ()
 
uint32_t getGeneration () const
 Get the current generation of this AST source. More...
 
virtual DeclGetExternalDecl (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 StmtGetExternalDeclStmt (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 CXXBaseSpecifierGetExternalCXXBaseSpecifiers (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 bool FindExternalVisibleDeclsByName (const DeclContext *DC, DeclarationName Name)
 Find all declarations with the given name in the given context, and add them to the context by calling SetExternalVisibleDeclsForName or SetNoExternalVisibleDeclsForName. More...
 
virtual void completeVisibleDeclsMap (const DeclContext *DC)
 Ensures that the table of all visible declarations inside this context is up to date. More...
 
virtual ModulegetModule (unsigned ID)
 Retrieve the module that corresponds to the given module ID. More...
 
virtual llvm::Optional< ASTSourceDescriptorgetSourceDescriptor (unsigned ID)
 Return a descriptor for the corresponding module, if one exists. More...
 
virtual ExtKind hasExternalDefinitions (const Decl *D)
 
virtual void FindExternalLexicalDecls (const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl *> &Result)
 Finds all declarations lexically contained within the given DeclContext, after applying an optional filter predicate. More...
 
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 CompleteType (TagDecl *Tag)
 Gives the external AST source an opportunity to complete an incomplete type. More...
 
virtual void CompleteType (ObjCInterfaceDecl *Class)
 Gives the external AST source an opportunity to complete an incomplete Objective-C class. 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
 

Protected Member Functions

uint32_t incrementGeneration (ASTContext &C)
 Increment the current generation. More...
 

Static Protected Member Functions

static DeclContextLookupResult SetExternalVisibleDeclsForName (const DeclContext *DC, DeclarationName Name, ArrayRef< NamedDecl *> Decls)
 
static DeclContextLookupResult SetNoExternalVisibleDeclsForName (const DeclContext *DC, DeclarationName Name)
 

Friends

class ExternalSemaSource
 

Detailed Description

Abstract interface for external sources of AST nodes.

External AST sources provide AST nodes constructed from some external source, such as a precompiled header. External AST sources can resolve types and declarations from abstract IDs into actual type and declaration nodes, and read parts of declaration contexts.

Definition at line 64 of file ExternalASTSource.h.

Member Enumeration Documentation

◆ ExtKind

Enumerator
EK_Always 
EK_Never 
EK_ReplyHazy 

Definition at line 195 of file ExternalASTSource.h.

Constructor & Destructor Documentation

◆ ExternalASTSource()

clang::ExternalASTSource::ExternalASTSource ( )
default

◆ ~ExternalASTSource()

ExternalASTSource::~ExternalASTSource ( )
virtualdefault

Member Function Documentation

◆ CompleteRedeclChain()

void ExternalASTSource::CompleteRedeclChain ( const Decl D)
virtual

Gives the external AST source an opportunity to complete the redeclaration chain for a declaration.

Called each time we need the most recent declaration of a declaration after the generation count is incremented.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 59 of file ExternalASTSource.cpp.

Referenced by clang::ASTContext::getTargetAddressSpace().

◆ CompleteType() [1/2]

void ExternalASTSource::CompleteType ( TagDecl Tag)
virtual

Gives the external AST source an opportunity to complete an incomplete type.

Reimplemented in clang::ExternalASTMerger, and clang::MultiplexExternalSemaSource.

Definition at line 61 of file ExternalASTSource.cpp.

Referenced by clang::ExternalASTMerger::CompleteType().

◆ CompleteType() [2/2]

void ExternalASTSource::CompleteType ( ObjCInterfaceDecl Class)
virtual

Gives the external AST source an opportunity to complete an incomplete Objective-C class.

This routine will only be invoked if the "externally completed" bit is set on the ObjCInterfaceDecl via the function ObjCInterfaceDecl::setExternallyCompleted().

Reimplemented in clang::MultiplexExternalSemaSource, and clang::ExternalASTMerger.

Definition at line 63 of file ExternalASTSource.cpp.

◆ completeVisibleDeclsMap()

void ExternalASTSource::completeVisibleDeclsMap ( const DeclContext DC)
virtual

Ensures that the table of all visible declarations inside this context is up to date.

The default implementation of this function is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 115 of file ExternalASTSource.cpp.

Referenced by clang::DeclContext::lookups().

◆ FindExternalLexicalDecls() [1/2]

void ExternalASTSource::FindExternalLexicalDecls ( const DeclContext DC,
llvm::function_ref< bool(Decl::Kind)>  IsKindWeWant,
SmallVectorImpl< Decl *> &  Result 
)
virtual

Finds all declarations lexically contained within the given DeclContext, after applying an optional filter predicate.

Parameters
IsKindWeWanta predicate function that returns true if the passed declaration kind is one we are looking for.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, clang::ExternalASTMerger, and clang::MultiplexExternalSemaSource.

Definition at line 117 of file ExternalASTSource.cpp.

Referenced by FindExternalLexicalDecls(), and clang::RecordDecl::isMsStruct().

◆ FindExternalLexicalDecls() [2/2]

void clang::ExternalASTSource::FindExternalLexicalDecls ( const DeclContext DC,
SmallVectorImpl< Decl *> &  Result 
)
inline

Finds all declarations lexically contained within the given DeclContext.

Definition at line 213 of file ExternalASTSource.h.

References FindExternalLexicalDecls(), FindFileRegionDecls(), and clang::Result.

◆ FindExternalVisibleDeclsByName()

bool ExternalASTSource::FindExternalVisibleDeclsByName ( const DeclContext DC,
DeclarationName  Name 
)
virtual

Find all declarations with the given name in the given context, and add them to the context by calling SetExternalVisibleDeclsForName or SetNoExternalVisibleDeclsForName.

Returns
true if any declarations might have been found, false if we definitely have no declarations with tbis name.

The default implementation of this method is a no-op returning false.

Reimplemented in clang::ASTReader, clang::ExternalASTMerger, and clang::MultiplexExternalSemaSource.

Definition at line 110 of file ExternalASTSource.cpp.

Referenced by updateOutOfDateIdentifier().

◆ FindFileRegionDecls()

void ExternalASTSource::FindFileRegionDecls ( FileID  File,
unsigned  Offset,
unsigned  Length,
SmallVectorImpl< Decl *> &  Decls 
)
virtual

Get the decls that are contained in a file in the Offset/Length range.

Length can be 0 to indicate a point at Offset instead of a range.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 55 of file ExternalASTSource.cpp.

Referenced by FindExternalLexicalDecls().

◆ FinishedDeserializing()

void ExternalASTSource::FinishedDeserializing ( )
virtual

Notify ExternalASTSource that we finished the deserialization of a decl or type.

Must be paired with StartedDeserializing.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 69 of file ExternalASTSource.cpp.

Referenced by clang::ExternalASTSource::Deserializing::~Deserializing().

◆ GetExternalCXXBaseSpecifiers()

CXXBaseSpecifier * ExternalASTSource::GetExternalCXXBaseSpecifiers ( uint64_t  Offset)
virtual

Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 105 of file ExternalASTSource.cpp.

Referenced by getGeneration().

◆ GetExternalCXXCtorInitializers()

CXXCtorInitializer ** ExternalASTSource::GetExternalCXXCtorInitializers ( uint64_t  Offset)
virtual

Resolve the offset of a set of C++ constructor initializers in the decl stream into an array of initializers.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 100 of file ExternalASTSource.cpp.

Referenced by getGeneration().

◆ GetExternalDecl()

Decl * ExternalASTSource::GetExternalDecl ( uint32_t  ID)
virtual

Resolve a declaration ID into a declaration, potentially building a new declaration.

This method only needs to be implemented if the AST source ever passes back decl sets as VisibleDeclaration objects.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 83 of file ExternalASTSource.cpp.

Referenced by getGeneration(), and makeStandaloneDiagnostic().

◆ GetExternalDeclStmt()

Stmt * ExternalASTSource::GetExternalDeclStmt ( uint64_t  Offset)
virtual

Resolve the offset of a statement in the decl stream into a statement.

This operation is meant to be used via a LazyOffsetPtr. It only needs to be implemented if the AST source uses methods like FunctionDecl::setLazyBody when building decls.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 95 of file ExternalASTSource.cpp.

Referenced by getGeneration().

◆ GetExternalSelector()

Selector ExternalASTSource::GetExternalSelector ( uint32_t  ID)
virtual

Resolve a selector ID into a selector.

This operation only needs to be implemented if the AST source returns non-zero for GetNumKnownSelectors().

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 87 of file ExternalASTSource.cpp.

Referenced by getGeneration().

◆ getGeneration()

uint32_t clang::ExternalASTSource::getGeneration ( ) const
inline

Get the current generation of this AST source.

This number is incremented each time the AST source lazily extends an existing entity.

Definition at line 98 of file ExternalASTSource.h.

References GetExternalCXXBaseSpecifiers(), GetExternalCXXCtorInitializers(), GetExternalDecl(), GetExternalDeclStmt(), GetExternalSelector(), and GetNumExternalSelectors().

◆ getMemoryBufferSizes() [1/2]

MemoryBufferSizes clang::ExternalASTSource::getMemoryBufferSizes ( ) const
inline

Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memory.

Definition at line 318 of file ExternalASTSource.h.

References clang::C, incrementGeneration(), SetExternalVisibleDeclsForName(), and SetNoExternalVisibleDeclsForName().

Referenced by clang::MultiplexExternalSemaSource::getMemoryBufferSizes(), and clang::MultiplexExternalSemaSource::layoutRecordType().

◆ getMemoryBufferSizes() [2/2]

void ExternalASTSource::getMemoryBufferSizes ( MemoryBufferSizes sizes) const
virtual

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 121 of file ExternalASTSource.cpp.

◆ getModule()

virtual Module* clang::ExternalASTSource::getModule ( unsigned  ID)
inlinevirtual

Retrieve the module that corresponds to the given module ID.

Reimplemented in clang::ASTReader.

Definition at line 165 of file ExternalASTSource.h.

◆ GetNumExternalSelectors()

uint32_t ExternalASTSource::GetNumExternalSelectors ( )
virtual

Returns the number of selectors known to the external AST source.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 91 of file ExternalASTSource.cpp.

Referenced by getGeneration().

◆ getSourceDescriptor()

llvm::Optional< ExternalASTSource::ASTSourceDescriptor > ExternalASTSource::getSourceDescriptor ( unsigned  ID)
virtual

Return a descriptor for the corresponding module, if one exists.

Reimplemented in clang::ASTReader.

Definition at line 31 of file ExternalASTSource.cpp.

References clang::None.

Referenced by clang::ExternalASTSource::ASTSourceDescriptor::getModuleOrNull().

◆ hasExternalDefinitions()

ExternalASTSource::ExtKind ExternalASTSource::hasExternalDefinitions ( const Decl D)
virtual

◆ incrementGeneration()

uint32_t ExternalASTSource::incrementGeneration ( ASTContext C)
protected

Increment the current generation.

Definition at line 123 of file ExternalASTSource.cpp.

References clang::ASTContext::getExternalSource(), and P.

Referenced by getMemoryBufferSizes().

◆ layoutRecordType()

bool ExternalASTSource::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 
)
virtual

Perform layout on the given record.

This routine allows the external AST source to provide an specific layout for a record, overriding the layout that would normally be constructed. It is intended for clients who receive specific layout details rather than source code (such as LLDB). The client is expected to fill in the field offsets, base offsets, virtual base offsets, and complete object size.

Parameters
RecordThe record whose layout is being requested.
SizeThe final size of the record, in bits.
AlignmentThe final alignment of the record, in bits.
FieldOffsetsThe offset of each of the fields within the record, expressed in bits. All of the fields must be provided with offsets.
BaseOffsetsThe offset of each of the direct, non-virtual base classes. If any bases are not given offsets, the bases will be laid out according to the ABI.
VirtualBaseOffsetsThe offset of each of the virtual base classes (either direct or not). If any bases are not given offsets, the bases will be laid out according to the ABI.
Returns
true if the record layout was provided, false otherwise.

Reimplemented in clang::MultiplexExternalSemaSource, and clang::LayoutOverrideSource.

Definition at line 75 of file ExternalASTSource.cpp.

◆ PrintStats()

void ExternalASTSource::PrintStats ( )
virtual

Print any statistics that have been gathered regarding the external AST source.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 73 of file ExternalASTSource.cpp.

◆ ReadComments()

void ExternalASTSource::ReadComments ( )
virtual

Loads comment ranges.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 65 of file ExternalASTSource.cpp.

◆ SetExternalVisibleDeclsForName()

DeclContext::lookup_result ExternalASTSource::SetExternalVisibleDeclsForName ( const DeclContext DC,
DeclarationName  Name,
ArrayRef< NamedDecl *>  Decls 
)
staticprotected

◆ SetNoExternalVisibleDeclsForName()

DeclContext::lookup_result ExternalASTSource::SetNoExternalVisibleDeclsForName ( const DeclContext DC,
DeclarationName  Name 
)
staticprotected

Definition at line 1257 of file DeclBase.cpp.

Referenced by getMemoryBufferSizes().

◆ StartedDeserializing()

void ExternalASTSource::StartedDeserializing ( )
virtual

Notify ExternalASTSource that we started deserialization of a decl or type so until FinishedDeserializing is called there may be decls that are initializing.

Must be paired with FinishedDeserializing.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 67 of file ExternalASTSource.cpp.

Referenced by clang::ExternalASTSource::Deserializing::Deserializing().

◆ StartTranslationUnit()

void ExternalASTSource::StartTranslationUnit ( ASTConsumer Consumer)
virtual

Function that will be invoked when we begin parsing a new translation unit involving this external AST source.

The default implementation of this method is a no-op.

Reimplemented in clang::ASTReader, and clang::MultiplexExternalSemaSource.

Definition at line 71 of file ExternalASTSource.cpp.

◆ updateOutOfDateIdentifier()

virtual void clang::ExternalASTSource::updateOutOfDateIdentifier ( IdentifierInfo II)
inlinevirtual

Update an out-of-date identifier.

Reimplemented in clang::ASTReader.

Definition at line 146 of file ExternalASTSource.h.

References FindExternalVisibleDeclsByName().

Referenced by clang::Decl::updateOutOfDate().

Friends And Related Function Documentation

◆ ExternalSemaSource

friend class ExternalSemaSource
friend

Definition at line 65 of file ExternalASTSource.h.


The documentation for this class was generated from the following files: