clang 22.0.0git
CGDebugInfo.cpp File Reference
#include "CGDebugInfo.h"
#include "CGBlocks.h"
#include "CGCXXABI.h"
#include "CGObjCRuntime.h"
#include "CGRecordLayout.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclFriend.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/VTableBuilder.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Version.h"
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/ModuleMap.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SHA1.h"
#include "llvm/Support/SHA256.h"
#include "llvm/Support/TimeProfiler.h"
#include <cstdint>
#include <optional>
#include "clang/AST/BuiltinTypes.def"
#include "clang/Basic/OpenCLImageTypes.def"
#include "clang/Basic/OpenCLExtensionTypes.def"
#include "clang/Basic/HLSLIntangibleTypes.def"
#include "clang/Basic/AArch64ACLETypes.def"
#include "clang/Basic/PPCTypes.def"
#include "clang/Basic/RISCVVTypes.def"
#include "clang/Basic/WebAssemblyReferenceTypes.def"
#include "clang/Basic/AMDGPUTypes.def"
#include "clang/AST/TypeNodes.inc"
#include "clang/Basic/Sanitizers.def"

Go to the source code of this file.

Macros

#define BUILTIN_TYPE(Id, SingletonId)
#define PLACEHOLDER_TYPE(Id, SingletonId)
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext)
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
#define SVE_TYPE(Name, Id, SingletonId)
#define PPC_VECTOR_TYPE(Name, Id, size)
#define RVV_TYPE(Name, Id, SingletonId)
#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS)
#define AMDGPU_OPAQUE_PTR_TYPE(Name, Id, SingletonId, Width, Align, AS)
#define AMDGPU_NAMED_BARRIER_TYPE(Name, Id, SingletonId, Width, Align, Scope)
#define CC_VLS_CASE(ABI_VLEN)
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base)
#define SANITIZER_CHECK(Enum, Name, Version, Msg)
#define SANITIZER(NAME, ID)

Functions

static uint32_t getTypeAlignIfRequired (const Type *Ty, const ASTContext &Ctx)
static uint32_t getTypeAlignIfRequired (QualType Ty, const ASTContext &Ctx)
static uint32_t getDeclAlignIfRequired (const Decl *D, const ASTContext &Ctx)
static bool IsDecomposedVarDecl (VarDecl const *VD)
 Returns true if VD is a a holding variable (aka a VarDecl retrieved using BindingDecl::getHoldingVar).
static bool IsArtificial (VarDecl const *VD)
 Returns true if VD is a compiler-generated variable and should be treated as artificial for the purposes of debug-info generation.
static void stripUnusedQualifiers (Qualifiers &Q)
static llvm::dwarf::Tag getNextQualifier (Qualifiers &Q)
static bool hasCXXMangling (const TagDecl *TD, llvm::DICompileUnit *TheCU)
static bool needsTypeIdentifier (const TagDecl *TD, CodeGenModule &CGM, llvm::DICompileUnit *TheCU)
static SmallString< 256 > getTypeIdentifier (const TagType *Ty, CodeGenModule &CGM, llvm::DICompileUnit *TheCU)
static llvm::dwarf::Tag getTagForRecord (const RecordDecl *RD)
static llvm::SmallVector< TemplateArgumentGetTemplateArgs (const TemplateDecl *TD, const TemplateSpecializationType *Ty)
static llvm::DINode::DIFlags getAccessFlag (AccessSpecifier Access, const RecordDecl *RD)
 Convert an AccessSpecifier into the corresponding DINode flag.
static unsigned getDwarfCC (CallingConv CC)
static llvm::DINode::DIFlags getRefFlags (const FunctionProtoType *Func)
static bool isFunctionLocalClass (const CXXRecordDecl *RD)
 isFunctionLocalClass - Return true if CXXRecordDecl is defined inside a function.
static bool isClassOrMethodDLLImport (const CXXRecordDecl *RD)
 Return true if the class or any of its methods are marked dllimport.
static bool isDefinedInClangModule (const RecordDecl *RD)
 Does a type definition exist in an imported clang module?
static bool hasExplicitMemberDefinition (CXXRecordDecl::method_iterator I, CXXRecordDecl::method_iterator End)
static bool canUseCtorHoming (const CXXRecordDecl *RD)
static bool shouldOmitDefinition (llvm::codegenoptions::DebugInfoKind DebugKind, bool DebugTypeExtRefs, const RecordDecl *RD, const LangOptions &LangOpts)
static bool hasDefaultGetterName (const ObjCPropertyDecl *PD, const ObjCMethodDecl *Getter)
static bool hasDefaultSetterName (const ObjCPropertyDecl *PD, const ObjCMethodDecl *Setter)
static auto getEnumInfo (CodeGenModule &CGM, llvm::DICompileUnit *TheCU, const EnumType *Ty)
static QualType UnwrapTypeForDebugInfo (QualType T, const ASTContext &C)
static bool ReferencesAnonymousEntity (ArrayRef< TemplateArgument > Args)
static bool ReferencesAnonymousEntity (RecordType *RT)
static bool IsReconstitutableType (QualType QT)
static std::string SanitizerHandlerToCheckLabel (SanitizerHandler Handler)
static std::string SanitizerOrdinalToCheckLabel (SanitizerKind::SanitizerOrdinal Ordinal)

Macro Definition Documentation

◆ ABSTRACT_TYPE

#define ABSTRACT_TYPE ( Class,
Base )

◆ AMDGPU_NAMED_BARRIER_TYPE

#define AMDGPU_NAMED_BARRIER_TYPE ( Name,
Id,
SingletonId,
Width,
Align,
Scope )
Value:
case BuiltinType::Id: { \
if (!SingletonId) \
SingletonId = \
DBuilder.createBasicType(Name, Width, llvm::dwarf::DW_ATE_unsigned); \
return SingletonId; \
}

◆ AMDGPU_OPAQUE_PTR_TYPE

#define AMDGPU_OPAQUE_PTR_TYPE ( Name,
Id,
SingletonId,
Width,
Align,
AS )
Value:
case BuiltinType::Id: { \
if (!SingletonId) \
SingletonId = \
DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name, \
TheCU, TheCU->getFile(), 0); \
return SingletonId; \
}

◆ BUILTIN_TYPE

#define BUILTIN_TYPE ( Id,
SingletonId )

◆ CC_VLS_CASE

#define CC_VLS_CASE ( ABI_VLEN)
Value:
case CC_RISCVVLSCall_##ABI_VLEN:

◆ DEPENDENT_TYPE

#define DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ EXT_OPAQUE_TYPE

#define EXT_OPAQUE_TYPE ( ExtType,
Id,
Ext )
Value:
case BuiltinType::Id: \
return getOrCreateStructPtrType("opencl_" #ExtType, Id##Ty);

◆ HLSL_INTANGIBLE_TYPE

#define HLSL_INTANGIBLE_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id: \
return getOrCreateStructPtrType(#Name, SingletonId);

◆ IMAGE_TYPE

#define IMAGE_TYPE ( ImgType,
Id,
SingletonId,
Access,
Suffix )
Value:
case BuiltinType::Id: \
return getOrCreateStructPtrType("opencl_" #ImgType "_" #Suffix "_t", \
SingletonId);

◆ NON_CANONICAL_TYPE

#define NON_CANONICAL_TYPE ( Class,
Base )

◆ PLACEHOLDER_TYPE

#define PLACEHOLDER_TYPE ( Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ PPC_VECTOR_TYPE

#define PPC_VECTOR_TYPE ( Name,
Id,
size )
Value:
case BuiltinType::Id:

◆ RVV_TYPE

#define RVV_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ SANITIZER

#define SANITIZER ( NAME,
ID )
Value:
case SanitizerKind::SO_##ID: \
Label = "__ubsan_check_" NAME; \
break;

◆ SANITIZER_CHECK

#define SANITIZER_CHECK ( Enum,
Name,
Version,
Msg )
Value:
case Enum: \
Label = "__ubsan_check_" #Name; \
break;
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5877

◆ SVE_TYPE

#define SVE_TYPE ( Name,
Id,
SingletonId )
Value:
case BuiltinType::Id:

◆ TYPE

#define TYPE ( Class,
Base )

◆ WASM_REF_TYPE

#define WASM_REF_TYPE ( Name,
MangledName,
Id,
SingletonId,
AS )
Value:
case BuiltinType::Id: { \
if (!SingletonId) \
SingletonId = \
DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, \
MangledName, TheCU, TheCU->getFile(), 0); \
return SingletonId; \
}

Function Documentation

◆ canUseCtorHoming()

◆ getAccessFlag()

llvm::DINode::DIFlags getAccessFlag ( AccessSpecifier Access,
const RecordDecl * RD )
static

Convert an AccessSpecifier into the corresponding DINode flag.

As an optimization, return 0 if the access specifier equals the default for the containing type.

Definition at line 1591 of file CGDebugInfo.cpp.

References clang::AS_none, clang::AS_private, clang::AS_protected, clang::AS_public, clang::Default, clang::TagDecl::isClass(), clang::TagDecl::isStruct(), and clang::TagDecl::isUnion().

Referenced by clang::CodeGen::CGDebugInfo::emitVTableSymbol().

◆ getDeclAlignIfRequired()

◆ getDwarfCC()

◆ getEnumInfo()

◆ getNextQualifier()

◆ getRefFlags()

llvm::DINode::DIFlags getRefFlags ( const FunctionProtoType * Func)
static

Definition at line 1709 of file CGDebugInfo.cpp.

References clang::Func, clang::RQ_LValue, and clang::RQ_RValue.

◆ getTagForRecord()

llvm::dwarf::Tag getTagForRecord ( const RecordDecl * RD)
static
Returns
the appropriate DWARF tag for a composite type.

Definition at line 1306 of file CGDebugInfo.cpp.

References clang::TagDecl::isClass(), clang::TagDecl::isInterface(), clang::TagDecl::isStruct(), and clang::TagDecl::isUnion().

◆ GetTemplateArgs()

llvm::SmallVector< TemplateArgument > GetTemplateArgs ( const TemplateDecl * TD,
const TemplateSpecializationType * Ty )
static

◆ getTypeAlignIfRequired() [1/2]

uint32_t getTypeAlignIfRequired ( const Type * Ty,
const ASTContext & Ctx )
static

◆ getTypeAlignIfRequired() [2/2]

uint32_t getTypeAlignIfRequired ( QualType Ty,
const ASTContext & Ctx )
static

Definition at line 75 of file CGDebugInfo.cpp.

References getTypeAlignIfRequired(), and clang::QualType::getTypePtr().

◆ getTypeIdentifier()

◆ hasCXXMangling()

bool hasCXXMangling ( const TagDecl * TD,
llvm::DICompileUnit * TheCU )
static
Returns
whether a C++ mangling exists for the type defined by TD.

Definition at line 1233 of file CGDebugInfo.cpp.

References clang::isa().

Referenced by needsTypeIdentifier().

◆ hasDefaultGetterName()

bool hasDefaultGetterName ( const ObjCPropertyDecl * PD,
const ObjCMethodDecl * Getter )
static

◆ hasDefaultSetterName()

bool hasDefaultSetterName ( const ObjCPropertyDecl * PD,
const ObjCMethodDecl * Setter )
static

◆ hasExplicitMemberDefinition()

bool hasExplicitMemberDefinition ( CXXRecordDecl::method_iterator I,
CXXRecordDecl::method_iterator End )
static

◆ IsArtificial()

bool IsArtificial ( VarDecl const * VD)
static

Returns true if VD is a compiler-generated variable and should be treated as artificial for the purposes of debug-info generation.

Definition at line 101 of file CGDebugInfo.cpp.

References clang::cast(), clang::Decl::getDeclContext(), clang::isa(), IsDecomposedVarDecl(), and clang::Decl::isImplicit().

◆ isClassOrMethodDLLImport()

bool isClassOrMethodDLLImport ( const CXXRecordDecl * RD)
static

Return true if the class or any of its methods are marked dllimport.

Definition at line 2872 of file CGDebugInfo.cpp.

References clang::Decl::hasAttr(), and clang::CXXRecordDecl::methods().

Referenced by canUseCtorHoming(), clang::CodeGen::CGDebugInfo::completeClassData(), and shouldOmitDefinition().

◆ IsDecomposedVarDecl()

bool IsDecomposedVarDecl ( VarDecl const * VD)
static

Returns true if VD is a a holding variable (aka a VarDecl retrieved using BindingDecl::getHoldingVar).

Definition at line 85 of file CGDebugInfo.cpp.

References clang::VarDecl::getInit(), and clang::Init.

Referenced by IsArtificial().

◆ isDefinedInClangModule()

◆ isFunctionLocalClass()

bool isFunctionLocalClass ( const CXXRecordDecl * RD)
static

isFunctionLocalClass - Return true if CXXRecordDecl is defined inside a function.

Definition at line 2172 of file CGDebugInfo.cpp.

References clang::Decl::getDeclContext(), clang::isa(), and isFunctionLocalClass().

Referenced by isFunctionLocalClass().

◆ IsReconstitutableType()

bool IsReconstitutableType ( QualType QT)
static

Definition at line 5775 of file CGDebugInfo.cpp.

References clang::T.

◆ needsTypeIdentifier()

bool needsTypeIdentifier ( const TagDecl * TD,
CodeGenModule & CGM,
llvm::DICompileUnit * TheCU )
static

◆ ReferencesAnonymousEntity() [1/2]

◆ ReferencesAnonymousEntity() [2/2]

bool ReferencesAnonymousEntity ( RecordType * RT)
static

◆ SanitizerHandlerToCheckLabel()

std::string SanitizerHandlerToCheckLabel ( SanitizerHandler Handler)
static

◆ SanitizerOrdinalToCheckLabel()

std::string SanitizerOrdinalToCheckLabel ( SanitizerKind::SanitizerOrdinal Ordinal)
static

◆ shouldOmitDefinition()

◆ stripUnusedQualifiers()

◆ UnwrapTypeForDebugInfo()

QualType UnwrapTypeForDebugInfo ( QualType T,
const ASTContext & C )
static