LLDB
mainline
|
Manages and observes all Clang AST node importing in LLDB. More...
#include <ClangASTImporter.h>
Classes | |
class | ASTContextMetadata |
struct | ASTImporterDelegate |
ASTImporter that intercepts and records the import process of the underlying ASTImporter. More... | |
struct | DeclOrigin |
struct | LayoutInfo |
class | MapCompleter |
struct | NewDeclListener |
Listener interface used by the ASTImporterDelegate to inform other code about decls that have been imported the first time. More... | |
Public Types | |
typedef std::pair< lldb::ModuleSP, CompilerDeclContext > | NamespaceMapItem |
typedef std::vector< NamespaceMapItem > | NamespaceMap |
typedef std::shared_ptr< NamespaceMap > | NamespaceMapSP |
typedef std::shared_ptr< ASTImporterDelegate > | ImporterDelegateSP |
typedef llvm::DenseMap< clang::ASTContext *, ImporterDelegateSP > | DelegateMap |
typedef llvm::DenseMap< const clang::NamespaceDecl *, NamespaceMapSP > | NamespaceMetaMap |
typedef std::shared_ptr< ASTContextMetadata > | ASTContextMetadataSP |
typedef llvm::DenseMap< const clang::ASTContext *, ASTContextMetadataSP > | ContextMetadataMap |
typedef llvm::DenseMap< const clang::RecordDecl *, LayoutInfo > | RecordDeclToLayoutMap |
Public Member Functions | |
ClangASTImporter () | |
CompilerType | CopyType (TypeSystemClang &dst, const CompilerType &src_type) |
Copies the given type and the respective declarations to the destination type system. More... | |
clang::Decl * | CopyDecl (clang::ASTContext *dst_ctx, clang::Decl *decl) |
CompilerType | DeportType (TypeSystemClang &dst, const CompilerType &src_type) |
Copies the given type and the respective declarations to the destination type system. More... | |
clang::Decl * | DeportDecl (clang::ASTContext *dst_ctx, clang::Decl *decl) |
Copies the given decl to the destination type system. More... | |
void | SetRecordLayout (clang::RecordDecl *decl, const LayoutInfo &layout) |
Sets the layout for the given RecordDecl. More... | |
bool | LayoutRecordType (const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets) |
bool | CanImport (const CompilerType &type) |
Returns true iff the given type was copied from another TypeSystemClang and the original type in this other TypeSystemClang might contain additional information (e.g., the definition of a 'class' type) that could be imported. More... | |
bool | Import (const CompilerType &type) |
If the given type was copied from another TypeSystemClang then copy over all missing information (e.g., the definition of a 'class' type). More... | |
bool | CompleteType (const CompilerType &compiler_type) |
bool | CompleteTagDecl (clang::TagDecl *decl) |
bool | CompleteTagDeclWithOrigin (clang::TagDecl *decl, clang::TagDecl *origin) |
bool | CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl) |
bool | CompleteAndFetchChildren (clang::QualType type) |
bool | RequireCompleteType (clang::QualType type) |
void | SetDeclOrigin (const clang::Decl *decl, clang::Decl *original_decl) |
Updates the internal origin-tracking information so that the given 'original' decl is from now on used to import additional information into the given decl. More... | |
ClangASTMetadata * | GetDeclMetadata (const clang::Decl *decl) |
void | RegisterNamespaceMap (const clang::NamespaceDecl *decl, NamespaceMapSP &namespace_map) |
NamespaceMapSP | GetNamespaceMap (const clang::NamespaceDecl *decl) |
void | BuildNamespaceMap (const clang::NamespaceDecl *decl) |
void | InstallMapCompleter (clang::ASTContext *dst_ctx, MapCompleter &completer) |
void | ForgetDestination (clang::ASTContext *dst_ctx) |
void | ForgetSource (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) |
ASTContextMetadataSP | GetContextMetadata (clang::ASTContext *dst_ctx) |
ASTContextMetadataSP | MaybeGetContextMetadata (clang::ASTContext *dst_ctx) |
ImporterDelegateSP | GetDelegate (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) |
DeclOrigin | GetDeclOrigin (const clang::Decl *decl) |
Public Attributes | |
ContextMetadataMap | m_metadata_map |
clang::FileManager | m_file_manager |
RecordDeclToLayoutMap | m_record_decl_to_layout_map |
Manages and observes all Clang AST node importing in LLDB.
The ClangASTImporter takes care of two things:
Clang's ASTImporter takes care of importing types from one ASTContext to another. This class expands this concept by allowing copying from several ASTContext instances to several other ASTContext instances. Instead of constructing a new ASTImporter manually to copy over a type/decl, this class can be asked to do this. It will construct a ASTImporter for the caller (and will cache the ASTImporter instance for later use) and then perform the import.
This mainly prevents that a caller might construct several ASTImporter instances for the same source/target ASTContext combination. As the ASTImporter has an internal state that keeps track of already imported declarations and so on, using only one ASTImporter instance is more efficient and less error-prone than using multiple.
Definition at line 64 of file ClangASTImporter.h.
typedef std::shared_ptr<ASTContextMetadata> lldb_private::ClangASTImporter::ASTContextMetadataSP |
Definition at line 408 of file ClangASTImporter.h.
typedef llvm::DenseMap<const clang::ASTContext *, ASTContextMetadataSP> lldb_private::ClangASTImporter::ContextMetadataMap |
Definition at line 410 of file ClangASTImporter.h.
typedef llvm::DenseMap<clang::ASTContext *, ImporterDelegateSP> lldb_private::ClangASTImporter::DelegateMap |
Definition at line 340 of file ClangASTImporter.h.
typedef std::shared_ptr<ASTImporterDelegate> lldb_private::ClangASTImporter::ImporterDelegateSP |
Definition at line 339 of file ClangASTImporter.h.
typedef std::vector<NamespaceMapItem> lldb_private::ClangASTImporter::NamespaceMap |
Definition at line 177 of file ClangASTImporter.h.
typedef std::pair<lldb::ModuleSP, CompilerDeclContext> lldb_private::ClangASTImporter::NamespaceMapItem |
Definition at line 176 of file ClangASTImporter.h.
typedef std::shared_ptr<NamespaceMap> lldb_private::ClangASTImporter::NamespaceMapSP |
Definition at line 178 of file ClangASTImporter.h.
typedef llvm::DenseMap<const clang::NamespaceDecl *, NamespaceMapSP> lldb_private::ClangASTImporter::NamespaceMetaMap |
Definition at line 342 of file ClangASTImporter.h.
typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> lldb_private::ClangASTImporter::RecordDeclToLayoutMap |
Definition at line 454 of file ClangASTImporter.h.
|
inline |
Definition at line 78 of file ClangASTImporter.h.
void ClangASTImporter::BuildNamespaceMap | ( | const clang::NamespaceDecl * | decl | ) |
Definition at line 755 of file ClangASTImporter.cpp.
References string().
bool ClangASTImporter::CanImport | ( | const CompilerType & | type | ) |
Returns true iff the given type was copied from another TypeSystemClang and the original type in this other TypeSystemClang might contain additional information (e.g., the definition of a 'class' type) that could be imported.
Definition at line 358 of file ClangASTImporter.cpp.
References lldb_private::ClangUtil::GetCanonicalQualType(), lldb_private::CompilerType::GetTypeSystem(), lldb_private::ClangUtil::IsClangType(), and lldb_private::ClangUtil::RemoveFastQualifiers().
Referenced by SymbolFileDWARF::CompleteType(), SymbolFileDWARF::HasForwardDeclForClangType(), and PrepareContextToReceiveMembers().
bool ClangASTImporter::CompleteAndFetchChildren | ( | clang::QualType | type | ) |
Definition at line 614 of file ClangASTImporter.cpp.
References lldb_private::ClangASTImporter::DeclOrigin::ctx, lldb_private::ClangASTImporter::DeclOrigin::decl, lldb_private::Expressions, lldb_private::GetLog(), LLDB_LOG_ERROR, RequireCompleteType(), and lldb_private::ClangASTImporter::DeclOrigin::Valid().
bool ClangASTImporter::CompleteObjCInterfaceDecl | ( | clang::ObjCInterfaceDecl * | interface_decl | ) |
bool ClangASTImporter::CompleteTagDecl | ( | clang::TagDecl * | decl | ) |
Definition at line 553 of file ClangASTImporter.cpp.
References lldb_private::ClangASTImporter::DeclOrigin::ctx, lldb_private::ClangASTImporter::DeclOrigin::decl, lldb_private::TypeSystemClang::GetCompleteDecl(), and lldb_private::ClangASTImporter::DeclOrigin::Valid().
Referenced by MaybeCompleteReturnType().
bool ClangASTImporter::CompleteTagDeclWithOrigin | ( | clang::TagDecl * | decl, |
clang::TagDecl * | origin | ||
) |
Definition at line 573 of file ClangASTImporter.cpp.
References lldb_private::TypeSystemClang::GetCompleteDecl().
bool ClangASTImporter::CompleteType | ( | const CompilerType & | compiler_type | ) |
Definition at line 505 of file ClangASTImporter.cpp.
References lldb_private::TypeSystemClang::CompleteTagDeclarationDefinition(), lldb_private::CompilerType::GetOpaqueQualType(), and lldb_private::TypeSystemClang::SetHasExternalStorage().
Referenced by SymbolFileDWARF::CompleteType(), and PDBASTParser::CompleteTypeFromPDB().
clang::Decl * ClangASTImporter::CopyDecl | ( | clang::ASTContext * | dst_ctx, |
clang::Decl * | decl | ||
) |
Definition at line 66 of file ClangASTImporter.cpp.
References lldb_private::Expressions, lldb_private::GetLog(), lldb_private::ClangASTMetadata::GetUserID(), LLDB_INVALID_UID, LLDB_LOG, and LLDB_LOG_ERROR.
CompilerType ClangASTImporter::CopyType | ( | TypeSystemClang & | dst, |
const CompilerType & | src_type | ||
) |
Copies the given type and the respective declarations to the destination type system.
This function does a shallow copy and requires that the target AST has an ExternalASTSource which queries this ClangASTImporter instance for any additional information that is maybe lacking in the shallow copy. This also means that the type system of src_type can not be deleted after this function has been called. If you need to delete the source type system you either need to delete the destination type system first or use ClangASTImporter::DeportType.
Definition at line 32 of file ClangASTImporter.cpp.
References lldb_private::Expressions, lldb_private::TypeSystemClang::getASTContext(), lldb_private::GetLog(), lldb_private::ClangUtil::GetQualType(), lldb_private::CompilerType::GetTypeSystem(), and LLDB_LOG_ERROR.
Referenced by DWARFASTParserClang::ParseTypeFromClangModule().
clang::Decl * ClangASTImporter::DeportDecl | ( | clang::ASTContext * | dst_ctx, |
clang::Decl * | decl | ||
) |
Copies the given decl to the destination type system.
Definition at line 327 of file ClangASTImporter.cpp.
References lldb_private::Expressions, lldb_private::GetLog(), LLDB_LOG, and DeclContextOverride::OverrideAllDeclsFromContainingFunction().
CompilerType ClangASTImporter::DeportType | ( | TypeSystemClang & | dst, |
const CompilerType & | src_type | ||
) |
Copies the given type and the respective declarations to the destination type system.
Unlike CopyType this function ensures that types/declarations which are originally from the AST of src_type are fully copied over. The type system of src_type can safely be deleted after calling this function.
Definition at line 304 of file ClangASTImporter.cpp.
References lldb_private::Expressions, lldb_private::TypeSystemClang::getASTContext(), lldb_private::GetLog(), lldb_private::CompilerType::GetOpaqueQualType(), lldb_private::ClangUtil::GetQualType(), lldb_private::CompilerType::GetTypeName(), lldb_private::CompilerType::GetTypeSystem(), LLDB_LOG, and DeclContextOverride::OverrideAllDeclsFromContainingFunction().
void ClangASTImporter::ForgetDestination | ( | clang::ASTContext * | dst_ctx | ) |
Definition at line 781 of file ClangASTImporter.cpp.
References lldb_private::Expressions, lldb_private::GetLog(), and LLDB_LOG.
void ClangASTImporter::ForgetSource | ( | clang::ASTContext * | dst_ctx, |
clang::ASTContext * | src_ctx | ||
) |
Definition at line 791 of file ClangASTImporter.cpp.
References lldb_private::Expressions, lldb_private::GetLog(), and LLDB_LOG.
Referenced by lldb_private::ScratchTypeSystemClang::ForgetSource().
|
inline |
Definition at line 414 of file ClangASTImporter.h.
References m_metadata_map.
Referenced by GetDelegate().
ClangASTMetadata * ClangASTImporter::GetDeclMetadata | ( | const clang::Decl * | decl | ) |
Definition at line 710 of file ClangASTImporter.cpp.
References lldb_private::ClangASTImporter::DeclOrigin::ctx, lldb_private::ClangASTImporter::DeclOrigin::decl, lldb_private::TypeSystemClang::GetASTContext(), lldb_private::TypeSystemClang::GetMetadata(), and lldb_private::ClangASTImporter::DeclOrigin::Valid().
ClangASTImporter::DeclOrigin ClangASTImporter::GetDeclOrigin | ( | const clang::Decl * | decl | ) |
Definition at line 722 of file ClangASTImporter.cpp.
|
inline |
Definition at line 434 of file ClangASTImporter.h.
References GetContextMetadata().
ClangASTImporter::NamespaceMapSP ClangASTImporter::GetNamespaceMap | ( | const clang::NamespaceDecl * | decl | ) |
Definition at line 743 of file ClangASTImporter.cpp.
bool ClangASTImporter::Import | ( | const CompilerType & | type | ) |
If the given type was copied from another TypeSystemClang then copy over all missing information (e.g., the definition of a 'class' type).
Definition at line 432 of file ClangASTImporter.cpp.
References lldb_private::ClangUtil::GetCanonicalQualType(), lldb_private::CompilerType::GetTypeSystem(), lldb_private::ClangUtil::IsClangType(), and lldb_private::ClangUtil::RemoveFastQualifiers().
|
inline |
Definition at line 200 of file ClangASTImporter.h.
References m_metadata_map.
bool ClangASTImporter::LayoutRecordType | ( | const clang::RecordDecl * | record_decl, |
uint64_t & | bit_size, | ||
uint64_t & | alignment, | ||
llvm::DenseMap< const clang::FieldDecl *, uint64_t > & | field_offsets, | ||
llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > & | base_offsets, | ||
llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > & | vbase_offsets | ||
) |
Definition at line 519 of file ClangASTImporter.cpp.
Referenced by lldb_private::TypeSystemClang::LayoutRecordType().
|
inline |
Definition at line 426 of file ClangASTImporter.h.
References m_metadata_map.
void ClangASTImporter::RegisterNamespaceMap | ( | const clang::NamespaceDecl * | decl, |
NamespaceMapSP & | namespace_map | ||
) |
Definition at line 735 of file ClangASTImporter.cpp.
bool ClangASTImporter::RequireCompleteType | ( | clang::QualType | type | ) |
Definition at line 684 of file ClangASTImporter.cpp.
References RequireCompleteType().
Referenced by DWARFASTParserClang::ParseTypeFromClangModule(), and PrepareContextToReceiveMembers().
void ClangASTImporter::SetDeclOrigin | ( | const clang::Decl * | decl, |
clang::Decl * | original_decl | ||
) |
Updates the internal origin-tracking information so that the given 'original' decl is from now on used to import additional information into the given decl.
Usually the origin-tracking in the ClangASTImporter is automatically updated when a declaration is imported, so the only valid reason to ever call this is if there is a 'better' original decl and the target decl is only a shallow clone that lacks any contents.
Definition at line 728 of file ClangASTImporter.cpp.
void ClangASTImporter::SetRecordLayout | ( | clang::RecordDecl * | decl, |
const LayoutInfo & | layout | ||
) |
Sets the layout for the given RecordDecl.
The layout will later be used by Clang's during code generation. Not calling this function for a RecordDecl will cause that Clang's codegen tries to layout the record by itself.
decl | The RecordDecl to set the layout for. |
layout | The layout for the record. |
Definition at line 548 of file ClangASTImporter.cpp.
Referenced by lldb_private::npdb::UdtRecordCompleter::complete(), DWARFASTParserClang::CompleteRecordType(), PDBASTParser::CompleteTypeFromUDT(), and DWARFASTParserClang::ParseStructureLikeDIE().
clang::FileManager lldb_private::ClangASTImporter::m_file_manager |
Definition at line 452 of file ClangASTImporter.h.
ContextMetadataMap lldb_private::ClangASTImporter::m_metadata_map |
Definition at line 412 of file ClangASTImporter.h.
Referenced by GetContextMetadata(), InstallMapCompleter(), and MaybeGetContextMetadata().
RecordDeclToLayoutMap lldb_private::ClangASTImporter::m_record_decl_to_layout_map |
Definition at line 456 of file ClangASTImporter.h.