LLDB mainline
Classes | Functions
ClangASTImporter.cpp File Reference
#include "lldb/Core/Module.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/RecordLayout.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Sema.h"
#include "llvm/Support/raw_ostream.h"
#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
#include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include <memory>
#include <optional>
#include <type_traits>

Go to the source code of this file.

Classes

class  DeclContextOverride
 
struct  DeclContextOverride::Backup
 

Functions

template<class D , class O >
static bool ImportOffsetMap (clang::ASTContext *dest_ctx, llvm::DenseMap< const D *, O > &destination_map, llvm::DenseMap< const D *, O > &source_map, ClangASTImporter &importer)
 Copy layout information from source_map to the destination_map.
 
template<bool IsVirtual>
bool ExtractBaseOffsets (const ASTRecordLayout &record_layout, DeclFromUser< const CXXRecordDecl > &record, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets)
 Given a CXXRecordDecl, will calculate and populate base_offsets with the integral offsets of any of its (possibly virtual) base classes.
 
static void MaybeCompleteReturnType (ClangASTImporter &importer, CXXMethodDecl *to_method)
 Takes a CXXMethodDecl and completes the return type if necessary.
 
static OptionalClangModuleID RemapModule (OptionalClangModuleID from_id, ClangExternalASTSourceCallbacks &from_source, ClangExternalASTSourceCallbacks &to_source)
 Recreate a module with its parents in to_source and return its id.
 

Function Documentation

◆ ExtractBaseOffsets()

template<bool IsVirtual>
bool ExtractBaseOffsets ( const ASTRecordLayout &  record_layout,
DeclFromUser< const CXXRecordDecl > &  record,
llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &  base_offsets 
)

Given a CXXRecordDecl, will calculate and populate base_offsets with the integral offsets of any of its (possibly virtual) base classes.

Parameters
[in]record_layoutASTRecordLayout of record.
[in]recordThe record that we're calculating the base layouts of.
[out]base_offsetsMap of base-class decl to integral offset which this function will fill in.
Returns
On success, will return 'true' and the offsets in base_offsets are usable.

Definition at line 581 of file ClangASTImporter.cpp.

References lldb_private::TaggedASTDecl< D >::decl, and lldb_private::TaggedASTDecl< D >::IsInvalid().

◆ ImportOffsetMap()

template<class D , class O >
static bool ImportOffsetMap ( clang::ASTContext *  dest_ctx,
llvm::DenseMap< const D *, O > &  destination_map,
llvm::DenseMap< const D *, O > &  source_map,
ClangASTImporter importer 
)
static

Copy layout information from source_map to the destination_map.

In the process of copying over layout info, we may need to import decls from the source_map. This function will use the supplied importer to import the necessary decls into dest_ctx.

Parameters
[in,out]dest_ctxDestination ASTContext into which we import decls from the source_map.
[out]destination_mapA map from decls in dest_ctx to an integral offest, which will be copies of the decl/offest pairs in source_map if successful.
[in]source_mapA map from decls to integral offests. These will be copied into destination_map.
[in,out]importerUsed to import decls into dest_ctx.
Returns
On success, will return 'true' and the offsets in destination_map are usable copies of source_map.

Definition at line 542 of file ClangASTImporter.cpp.

References lldb_private::TaggedASTDecl< D >::decl, lldb_private::DeclFromUser< D >::Import(), and lldb_private::TaggedASTDecl< D >::IsInvalid().

Referenced by lldb_private::ClangASTImporter::importRecordLayoutFromOrigin().

◆ MaybeCompleteReturnType()

static void MaybeCompleteReturnType ( ClangASTImporter importer,
CXXMethodDecl *  to_method 
)
static

Takes a CXXMethodDecl and completes the return type if necessary.

This is currently only necessary for virtual functions with covariant return types where Clang's CodeGen expects that the underlying records are already completed.

Definition at line 1246 of file ClangASTImporter.cpp.

References lldb_private::ClangASTImporter::CompleteTagDecl().

Referenced by lldb_private::ClangASTImporter::ASTImporterDelegate::Imported().

◆ RemapModule()

static OptionalClangModuleID RemapModule ( OptionalClangModuleID  from_id,
ClangExternalASTSourceCallbacks from_source,
ClangExternalASTSourceCallbacks to_source 
)
static