LLDB mainline
|
#include "TypeSystemClang.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/ExprCXX.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
#include <mutex>
#include <memory>
#include <string>
#include <vector>
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTImporter.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/Type.h"
#include "clang/AST/VTableBuilder.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/LangStandard.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/ModuleMap.h"
#include "clang/Sema/Sema.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/Threading.h"
#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
#include "Plugins/ExpressionParser/Clang/ClangFunctionCaller.h"
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Host/StreamFile.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Flags.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/ThreadSafeDenseMap.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
#include "Plugins/SymbolFile/PDB/PDBASTParser.h"
#include "Plugins/SymbolFile/NativePDB/PdbAstBuilder.h"
#include <cstdio>
#include <optional>
#include "clang/Basic/OperatorKinds.def"
#include "clang/Basic/AArch64SVEACLETypes.def"
#include "clang/Basic/RISCVVTypes.def"
#include "clang/Basic/AMDGPUTypes.def"
Go to the source code of this file.
Classes | |
class | NullDiagnosticConsumer |
Macros | |
#define | OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) |
#define | SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id: |
#define | RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id: |
#define | AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case clang::BuiltinType::Id: |
#define | DEPTH_INCREMENT 2 |
Typedefs | |
typedef lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > | ClangASTMap |
Functions | |
static lldb::addr_t | GetVTableAddress (Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout) |
static int64_t | ReadVBaseOffsetFromVTable (Process &process, VTableContextBase &vtable_ctx, lldb::addr_t vtable_ptr, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl) |
static bool | GetVBaseBitOffset (VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl, int32_t &bit_offset) |
static ClangASTMap & | GetASTMap () |
static void | SetMemberOwningModule (clang::Decl *member, const clang::Decl *parent) |
static void | ParseLangArgs (LangOptions &Opts, ArchSpec arch) |
static bool | QualTypeMatchesBitSize (const uint64_t bit_size, ASTContext &ast, QualType qual_type) |
static TemplateParameterList * | CreateTemplateParameterList (ASTContext &ast, const TypeSystemClang::TemplateParameterInfos &template_param_infos, llvm::SmallVector< NamedDecl *, 8 > &template_param_decls) |
static bool | TemplateParameterAllowsValue (NamedDecl *param, const TemplateArgument &value) |
Returns true if the given template parameter can represent the given value. | |
static bool | ClassTemplateAllowsToInstantiationArgs (ClassTemplateDecl *class_template_decl, const TypeSystemClang::TemplateParameterInfos &instantiation_values) |
Returns true if the given class template declaration could produce an instantiation with the specified values. | |
static bool | check_op_param (bool is_method, clang::OverloadedOperatorKind op_kind, bool unary, bool binary, uint32_t num_params) |
clang::DeclContext * | FindLCABetweenDecls (clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root) |
static QualType | RemoveWrappingTypes (QualType type, ArrayRef< clang::Type::TypeClass > mask={}) |
Aggressively desugar the provided type, skipping past various kinds of syntactic sugar and other constructs one typically wants to ignore. | |
static const clang::RecordType * | GetCompleteRecordType (clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion) |
Returns the clang::RecordType of the specified qual_type. | |
static const clang::EnumType * | GetCompleteEnumType (clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion) |
Returns the clang::EnumType of the specified qual_type. | |
static const clang::ObjCObjectType * | GetCompleteObjCObjectType (clang::ASTContext *ast, QualType qual_type, bool allow_completion) |
Returns the clang::ObjCObjectType of the specified qual_type. | |
static bool | GetCompleteQualType (clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion=true) |
static clang::ObjCIvarDecl::AccessControl | ConvertAccessTypeToObjCIvarAccessControl (AccessType access) |
static clang::QualType | GetFullyUnqualifiedType_Impl (clang::ASTContext *ast, clang::QualType qual_type) |
static bool | ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, bool check_superclass) |
static std::optional< SymbolFile::ArrayInfo > | GetDynamicArrayInfo (TypeSystemClang &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx) |
static lldb::opaque_compiler_type_t | GetObjCFieldAtIndex (clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) |
const TemplateArgument * | GetNthTemplateArgument (const clang::ClassTemplateSpecializationDecl *decl, size_t idx, bool expand_pack) |
static bool | DumpEnumValue (const clang::QualType &qual_type, Stream &s, const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_offset, uint32_t bitfield_bit_size) |
static CompilerContextKind | GetCompilerKind (clang::Decl::Kind clang_kind, clang::DeclContext const *decl_ctx) |
static void | InsertCompilerContext (TypeSystemClang *ts, clang::DeclContext *decl_ctx, std::vector< lldb_private::CompilerContext > &context) |
static bool | IsClangDeclContext (const CompilerDeclContext &dc) |
static llvm::StringRef | GetNameForIsolatedASTKind (ScratchTypeSystemClang::IsolatedASTKind kind) |
Returns a human-readable name that uniquely identifiers the sub-AST kind. | |
static llvm::StringRef | GetSpecializedASTName (ScratchTypeSystemClang::IsolatedASTKind feature) |
#define AMDGPU_TYPE | ( | Name, | |
Id, | |||
SingletonId, | |||
Width, | |||
Align | |||
) | case clang::BuiltinType::Id: |
#define DEPTH_INCREMENT 2 |
Definition at line 8570 of file TypeSystemClang.cpp.
#define OVERLOADED_OPERATOR | ( | Name, | |
Spelling, | |||
Token, | |||
Unary, | |||
Binary, | |||
MemberOnly | |||
) |
#define RVV_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | case clang::BuiltinType::Id: |
#define SVE_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | case clang::BuiltinType::Id: |
typedef lldb_private::ThreadSafeDenseMap<clang::ASTContext *, TypeSystemClang *> ClangASTMap |
Definition at line 319 of file TypeSystemClang.cpp.
|
inlinestatic |
Definition at line 1687 of file TypeSystemClang.cpp.
|
static |
Returns true if the given class template declaration could produce an instantiation with the specified values.
For example, <typename T>
allows the arguments float
, but not for example bool, float
or 3
(as an integer parameter value).
Definition at line 1489 of file TypeSystemClang.cpp.
References lldb_private::TypeSystemClang::TemplateParameterInfos::Front(), lldb_private::TypeSystemClang::TemplateParameterInfos::GetArgs(), lldb_private::TypeSystemClang::TemplateParameterInfos::GetParameterPack(), lldb_private::TypeSystemClang::TemplateParameterInfos::hasParameterPack(), lldb_private::TypeSystemClang::TemplateParameterInfos::IsEmpty(), lldb_private::TypeSystemClang::TemplateParameterInfos::Size(), and TemplateParameterAllowsValue().
Referenced by lldb_private::TypeSystemClang::CreateClassTemplateDecl().
|
static |
Definition at line 2775 of file TypeSystemClang.cpp.
References lldb::eAccessNone, lldb::eAccessPackage, lldb::eAccessPrivate, lldb::eAccessProtected, and lldb::eAccessPublic.
Referenced by lldb_private::TypeSystemClang::AddFieldToRecordType().
|
static |
Definition at line 1344 of file TypeSystemClang.cpp.
References lldb_private::TypeSystemClang::TemplateParameterInfos::Front(), lldb_private::TypeSystemClang::TemplateParameterInfos::GetArgs(), lldb_private::TypeSystemClang::TemplateParameterInfos::GetNames(), lldb_private::TypeSystemClang::TemplateParameterInfos::GetPackName(), lldb_private::TypeSystemClang::TemplateParameterInfos::GetParameterPack(), lldb_private::TypeSystemClang::TemplateParameterInfos::HasPackName(), lldb_private::TypeSystemClang::TemplateParameterInfos::hasParameterPack(), lldb_private::TypeSystemClang::TemplateParameterInfos::IsEmpty(), and lldb_private::TypeSystemClang::TemplateParameterInfos::Size().
Referenced by lldb_private::TypeSystemClang::CreateClassTemplateDecl(), lldb_private::TypeSystemClang::CreateFunctionTemplateDecl(), and lldb_private::TypeSystemClang::CreateTemplateTemplateParmDecl().
|
static |
Definition at line 8627 of file TypeSystemClang.cpp.
References lldb_private::DataExtractor::GetMaxS64Bitfield(), lldb_private::DataExtractor::GetMaxU64Bitfield(), lldb_private::Stream::Printf(), and lldb_private::Stream::PutCString().
Referenced by lldb_private::TypeSystemClang::DumpTypeValue().
clang::DeclContext * FindLCABetweenDecls | ( | clang::DeclContext * | left, |
clang::DeclContext * | right, | ||
clang::DeclContext * | root | ||
) |
Definition at line 1926 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::CreateUsingDirectiveDeclaration().
|
static |
Definition at line 321 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::CreateASTContext(), lldb_private::TypeSystemClang::Finalize(), and lldb_private::TypeSystemClang::GetASTContext().
|
static |
Definition at line 9172 of file TypeSystemClang.cpp.
References lldb_private::Any, lldb_private::ClassOrStruct, lldb_private::Enum, lldb_private::Function, lldb_private::Namespace, lldb_private::TranslationUnit, lldb_private::Typedef, lldb_private::Union, and lldb_private::Variable.
Referenced by lldb_private::TypeSystemClang::DeclGetCompilerContext(), and InsertCompilerContext().
|
static |
Returns the clang::EnumType of the specified qual_type.
This function will try to complete the type if necessary (and allowed by the specified allow_completion). If we fail to return a complete type, returns nullptr.
Definition at line 2638 of file TypeSystemClang.cpp.
Referenced by GetCompleteQualType().
|
static |
Returns the clang::ObjCObjectType of the specified qual_type.
This function will try to complete the type if necessary (and allowed by the specified allow_completion). If we fail to return a complete type, returns nullptr.
Definition at line 2675 of file TypeSystemClang.cpp.
Referenced by GetCompleteQualType().
|
static |
Definition at line 2710 of file TypeSystemClang.cpp.
References GetCompleteEnumType(), GetCompleteObjCObjectType(), GetCompleteQualType(), GetCompleteRecordType(), and RemoveWrappingTypes().
Referenced by GetCompleteQualType(), lldb_private::TypeSystemClang::GetCompleteType(), lldb_private::TypeSystemClang::GetMemberFunctionAtIndex(), lldb_private::TypeSystemClang::GetNumChildren(), lldb_private::TypeSystemClang::GetNumMemberFunctions(), and lldb_private::TypeSystemClang::IsCompleteType().
|
static |
Returns the clang::RecordType of the specified qual_type.
This function will try to complete the type if necessary (and allowed by the specified allow_completion). If we fail to return a complete type, returns nullptr.
Definition at line 2592 of file TypeSystemClang.cpp.
Referenced by GetCompleteQualType().
|
static |
Definition at line 5309 of file TypeSystemClang.cpp.
References lldb_private::SymbolFile::GetDynamicArrayInfoForUID(), and lldb_private::TypeSystemClang::GetMetadata().
Referenced by lldb_private::TypeSystemClang::GetNumChildren().
|
static |
Definition at line 4318 of file TypeSystemClang.cpp.
References GetFullyUnqualifiedType_Impl().
Referenced by lldb_private::TypeSystemClang::GetFullyUnqualifiedType(), and GetFullyUnqualifiedType_Impl().
|
static |
Returns a human-readable name that uniquely identifiers the sub-AST kind.
Definition at line 9698 of file TypeSystemClang.cpp.
References lldb_private::ScratchTypeSystemClang::CppModules.
Referenced by lldb_private::ScratchTypeSystemClang::Dump().
const TemplateArgument * GetNthTemplateArgument | ( | const clang::ClassTemplateSpecializationDecl * | decl, |
size_t | idx, | ||
bool | expand_pack | ||
) |
Definition at line 7248 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::GetIntegralTemplateArgument(), lldb_private::TypeSystemClang::GetTemplateArgumentKind(), and lldb_private::TypeSystemClang::GetTypeTemplateArgument().
|
static |
Definition at line 5647 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::GetFieldAtIndex().
|
static |
Definition at line 9788 of file TypeSystemClang.cpp.
References lldb_private::ScratchTypeSystemClang::CppModules.
Referenced by lldb_private::ScratchTypeSystemClang::GetIsolatedAST().
|
static |
Definition at line 292 of file TypeSystemClang.cpp.
References lldb_private::ValueObject::GetExecutionContextRef(), lldb_private::ExecutionContext::GetProcessPtr(), GetVTableAddress(), LLDB_INVALID_ADDRESS, and ReadVBaseOffsetFromVTable().
Referenced by lldb_private::TypeSystemClang::GetChildCompilerTypeAtIndex().
|
static |
Definition at line 202 of file TypeSystemClang.cpp.
References lldb_private::eAddressTypeLoad, lldb_private::Status::Fail(), lldb_private::DataExtractor::GetAddress(), lldb_private::DataExtractor::GetAddressByteSize(), lldb_private::ValueObject::GetAddressTypeOfChildren(), lldb_private::ValueObject::GetCompilerType(), lldb_private::ValueObject::GetData(), lldb_private::CompilerType::GetTypeInfo(), lldb_private::ValueObject::GetValueAsUnsigned(), LLDB_INVALID_ADDRESS, and lldb_private::Process::ReadPointerFromMemory().
Referenced by GetVBaseBitOffset().
|
static |
Definition at line 9199 of file TypeSystemClang.cpp.
References lldb_private::TypeSystemClang::DeclContextGetName(), GetCompilerKind(), and InsertCompilerContext().
Referenced by lldb_private::TypeSystemClang::DeclContextGetCompilerContext(), lldb_private::TypeSystemClang::DeclGetCompilerContext(), and InsertCompilerContext().
|
static |
Definition at line 9541 of file TypeSystemClang.cpp.
References lldb_private::CompilerDeclContext::GetTypeSystem(), and lldb_private::CompilerDeclContext::IsValid().
Referenced by lldb_private::TypeSystemClang::DeclContextGetAsCXXMethodDecl(), lldb_private::TypeSystemClang::DeclContextGetAsDeclContext(), lldb_private::TypeSystemClang::DeclContextGetAsFunctionDecl(), lldb_private::TypeSystemClang::DeclContextGetAsNamespaceDecl(), and lldb_private::TypeSystemClang::DeclContextGetAsObjCMethodDecl().
|
static |
Definition at line 5294 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::GetIndexOfChildMemberWithName(), lldb_private::TypeSystemClang::GetIndexOfChildWithName(), lldb_private::TypeSystemClang::GetNumChildren(), and lldb_private::TypeSystemClang::IsObjCClassTypeAndHasIVars().
|
static |
Definition at line 464 of file TypeSystemClang.cpp.
References lldb_private::ArchSpec::CharIsSignedByDefault(), and lldb_private::ArchSpec::GetTriple().
Referenced by lldb_private::TypeSystemClang::CreateASTContext().
|
inlinestatic |
Definition at line 753 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(), and lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize().
|
static |
Definition at line 259 of file TypeSystemClang.cpp.
References lldb_private::Process::GetAddressByteSize(), and lldb_private::Process::ReadSignedIntegerFromMemory().
Referenced by GetVBaseBitOffset().
|
static |
Aggressively desugar the provided type, skipping past various kinds of syntactic sugar and other constructs one typically wants to ignore.
The mask
argument allows one to skip certain kinds of simplifications, when one wishes to handle a certain kind of type directly.
Definition at line 2534 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::DumpTypeDescription(), lldb_private::TypeSystemClang::GetAsTemplateSpecialization(), lldb_private::TypeSystemClang::GetChildCompilerTypeAtIndex(), GetCompleteQualType(), lldb_private::TypeSystemClang::GetDeclContextForType(), lldb_private::TypeSystemClang::GetDirectBaseClassAtIndex(), lldb_private::TypeSystemClang::GetDirectNestedTypeWithName(), lldb_private::TypeSystemClang::GetEncoding(), lldb_private::TypeSystemClang::GetFieldAtIndex(), lldb_private::TypeSystemClang::GetFormat(), lldb_private::TypeSystemClang::GetIndexOfChildMemberWithName(), lldb_private::TypeSystemClang::GetIndexOfChildWithName(), lldb_private::TypeSystemClang::GetMemberFunctionAtIndex(), lldb_private::TypeSystemClang::GetNumChildren(), lldb_private::TypeSystemClang::GetNumDirectBaseClasses(), lldb_private::TypeSystemClang::GetNumFields(), lldb_private::TypeSystemClang::GetNumMemberFunctions(), lldb_private::TypeSystemClang::GetNumPointeeChildren(), lldb_private::TypeSystemClang::GetNumTemplateArguments(), lldb_private::TypeSystemClang::GetNumVirtualBaseClasses(), lldb_private::TypeSystemClang::GetStaticFieldWithName(), lldb_private::TypeSystemClang::GetTypeClass(), lldb_private::TypeSystemClang::GetTypedefedType(), lldb_private::TypeSystemClang::GetTypeInfo(), lldb_private::TypeSystemClang::GetTypeName(), lldb_private::TypeSystemClang::GetVirtualBaseClassAtIndex(), lldb_private::TypeSystemClang::IsAggregateType(), lldb_private::TypeSystemClang::IsAnonymousType(), lldb_private::TypeSystemClang::IsArrayType(), lldb_private::TypeSystemClang::IsHomogeneousAggregate(), lldb_private::TypeSystemClang::IsPointerOrReferenceType(), lldb_private::TypeSystemClang::IsPointerType(), lldb_private::TypeSystemClang::IsPossibleDynamicType(), lldb_private::TypeSystemClang::IsReferenceType(), lldb_private::TypeSystemClang::IsTypedefType(), lldb_private::TypeSystemClang::IsTypeImpl(), and lldb_private::TypeSystemClang::SetHasExternalStorage().
|
static |
Definition at line 343 of file TypeSystemClang.cpp.
Referenced by lldb_private::TypeSystemClang::AddEnumerationValueToEnumerationType(), lldb_private::TypeSystemClang::AddFieldToRecordType(), lldb_private::TypeSystemClang::AddMethodToCXXRecordType(), lldb_private::TypeSystemClang::AddMethodToObjCObjectType(), lldb_private::TypeSystemClang::AddObjCClassProperty(), lldb_private::TypeSystemClang::AddVariableToRecordType(), and lldb_private::TypeSystemClang::BuildIndirectFields().
|
static |
Returns true if the given template parameter can represent the given value.
For example, typename T
can represent int
but not integral values such as int I = 3
.
Definition at line 1452 of file TypeSystemClang.cpp.
References lldb_private::Expressions, lldb_private::GetLog(), LLDB_LOG, and lldbassert.
Referenced by ClassTemplateAllowsToInstantiationArgs().