65 const llvm::codegenoptions::DebugInfoKind DebugKind;
66 bool DebugTypeExtRefs;
67 llvm::DIBuilder DBuilder;
68 llvm::DICompileUnit *TheCU =
nullptr;
72 llvm::MDNode *CurInlinedAt =
nullptr;
73 llvm::DIType *VTablePtrType =
nullptr;
74 llvm::DIType *ClassTy =
nullptr;
75 llvm::DICompositeType *ObjTy =
nullptr;
76 llvm::DIType *SelTy =
nullptr;
77#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
78 llvm::DIType *SingletonId = nullptr;
79#include "clang/Basic/OpenCLImageTypes.def"
80 llvm::DIType *OCLSamplerDITy =
nullptr;
81 llvm::DIType *OCLEventDITy =
nullptr;
82 llvm::DIType *OCLClkEventDITy =
nullptr;
83 llvm::DIType *OCLQueueDITy =
nullptr;
84 llvm::DIType *OCLNDRangeDITy =
nullptr;
85 llvm::DIType *OCLReserveIDDITy =
nullptr;
86#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
87 llvm::DIType *Id##Ty = nullptr;
88#include "clang/Basic/OpenCLExtensionTypes.def"
89#define WASM_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
90#include "clang/Basic/WebAssemblyReferenceTypes.def"
91#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
92 llvm::DIType *SingletonId = nullptr;
93#include "clang/Basic/AMDGPUTypes.def"
94#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
95 llvm::DIType *SingletonId = nullptr;
96#include "clang/Basic/HLSLIntangibleTypes.def"
99 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
103 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
111 std::string remapPath(StringRef Path)
const override {
112 return Self.remapDIPath(Path);
115 PrintingCallbacks PrintCB = {*
this};
117 struct ObjCInterfaceCacheEntry {
118 const ObjCInterfaceType *Type;
121 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
123 : Type(Type), Decl(Decl), Unit(Unit) {}
127 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
132 llvm::DenseMap<
const ObjCInterfaceDecl *,
133 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
137 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
140 std::vector<void *> RetainedTypes;
143 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
147 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
151 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
152 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
156 std::vector<unsigned> FnBeginRegionCount;
160 llvm::BumpPtrAllocator DebugInfoNames;
162 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
163 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
167 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
168 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
169 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
170 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
172 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
173 StaticDataMemberCache;
175 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
176 using Param2DILocTy =
177 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
180 ParamDecl2StmtTy CoroutineParameterMappings;
182 Param2DILocTy ParamDbgMappings;
191 } KeyInstructionsInfo;
200 llvm::DIType *CreateType(
const BitIntType *Ty);
201 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
204 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
205 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
208 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
210 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
211 llvm::DIType *CreateType(
const HLSLAttributedResourceType *Ty,
213 llvm::DIType *CreateType(
const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
215 llvm::DIType *CreateType(
const RecordType *Tyg);
223 std::pair<llvm::DIType *, llvm::DIType *>
224 CreateTypeDefinition(
const RecordType *Ty);
225 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
227 llvm::DICompositeType *CT);
233 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
234 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
236 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
238 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
242 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
243 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
245 llvm::DIType *CreateEnumType(
const EnumType *Ty);
246 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
253 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
258 llvm::DIType *getTypeOrNull(
const QualType);
266 llvm::DISubroutineType *
270 llvm::DISubroutineType *
272 llvm::DIFile *Unit,
bool SkipFirst =
false);
273 llvm::DISubroutineType *
274 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
276 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
279 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
280 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
281 QualType PointeeTy, llvm::DIFile *F);
282 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
288 llvm::DIType *RecordTy);
302 llvm::DIType *RecordTy);
306 void CollectCXXBasesAux(
311 llvm::DINode::DIFlags StartingFlags);
319 struct TemplateArgs {
324 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
328 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
333 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
342 llvm::DINodeArray CollectCXXTemplateParams(
const RecordDecl *TS,
346 llvm::DINodeArray CollectBTFDeclTagAnnotations(
const Decl *D);
348 llvm::DIType *createFieldType(StringRef name,
QualType type,
350 uint64_t offsetInBits, uint32_t AlignInBits,
351 llvm::DIFile *tunit, llvm::DIScope *scope,
353 llvm::DINodeArray Annotations =
nullptr);
355 llvm::DIType *createFieldType(StringRef name,
QualType type,
357 uint64_t offsetInBits, llvm::DIFile *tunit,
358 llvm::DIScope *scope,
360 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
365 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
366 llvm::DIScope *RecordTy,
367 const RecordDecl *RD);
371 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
372 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
376 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
380 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
381 llvm::DIFile *FileScope);
385 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
386 SmallVectorImpl<llvm::Metadata *> &E,
387 llvm::DIType *RecordTy);
388 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
389 llvm::DIType *RecordTy,
390 const RecordDecl *RD);
391 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
393 SmallVectorImpl<llvm::Metadata *> &E,
394 llvm::DIType *RecordTy,
const RecordDecl *RD);
395 void CollectRecordNestedType(
const TypeDecl *RD,
396 SmallVectorImpl<llvm::Metadata *> &E);
397 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
398 SmallVectorImpl<llvm::Metadata *> &E,
399 llvm::DICompositeType *RecordTy);
403 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
404 SmallVectorImpl<llvm::Metadata *> &EltTys);
408 void CreateLexicalBlock(SourceLocation Loc);
416 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
417 SmallVectorImpl<uint64_t> &Expr)
const;
423 uint64_t collectDefaultElementTypesForBlockPointer(
424 const BlockPointerType *Ty, llvm::DIFile *Unit,
425 llvm::DIDerivedType *DescTy,
unsigned LineNo,
426 SmallVectorImpl<llvm::Metadata *> &EltTys);
430 void collectDefaultFieldsForBlockLiteralDeclare(
431 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
432 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
433 SmallVectorImpl<llvm::Metadata *> &Fields);
446 SizeExprCache[Ty] = SizeExpr;
475 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
497 llvm::Function *Fn,
bool CurFnIsThunk);
507 QualType FnType, llvm::Function *Fn =
nullptr);
530 llvm::DILocalVariable *
533 const bool UsePointerValue =
false);
542 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
546 llvm::DILocalVariable *
548 CGBuilderTy &Builder,
bool UsePointerValue =
false);
553 StringRef Name,
unsigned ArgNo,
554 llvm::AllocaInst *LocalAddr,
631 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
642 return CoroutineParameterMappings;
655 StringRef FailureMsg);
670 llvm::Value *Backup);
675 llvm::Value *Backup, uint64_t Atom);
685 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
691 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
692 std::optional<unsigned> ArgNo,
694 const bool UsePointerValue =
false);
699 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
700 std::optional<unsigned> ArgNo,
702 const bool UsePointerValue =
false);
704 struct BlockByRefType {
706 llvm::DIType *BlockByRefWrapper;
708 llvm::DIType *WrappedType;
712 std::string GetName(
const Decl *,
bool Qualified =
false)
const;
715 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
719 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
721 llvm::DIScope *getContextDescriptor(
const Decl *Context,
724 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
727 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
731 StringRef getCurrentDirname();
734 void CreateCompileUnit();
737 std::optional<llvm::DIFile::ChecksumKind>
750 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
751 std::optional<StringRef> Source);
754 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
759 bool CreateSkeletonCU);
762 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
766 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
769 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
772 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
773 StringRef Name, uint64_t *Offset);
777 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
781 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
790 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
791 unsigned LineNo, llvm::DINode::DIFlags Flags,
792 llvm::DISubprogram::DISPFlags SPFlags);
798 llvm::DIDerivedType *
799 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
802 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
806 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
810 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
814 llvm::DIGlobalVariable *
815 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
824 llvm::DIGlobalVariableExpression *
825 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
826 unsigned LineNo, StringRef LinkageName,
827 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
832 llvm::DINode::DIFlags getCallSiteRelatedAttrs()
const;
848 StringRef getSelectorName(
Selector S);
858 StringRef getDynamicInitializerName(
const VarDecl *VD,
860 llvm::Function *InitFn);
873 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
874 StringRef &Name, StringRef &LinkageName,
875 llvm::DIScope *&FDContext,
876 llvm::DINodeArray &TParamsArray,
877 llvm::DINode::DIFlags &Flags);
880 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
881 unsigned &LineNo,
QualType &
T, StringRef &Name,
882 StringRef &LinkageName,
883 llvm::MDTuple *&TemplateParameters,
884 llvm::DIScope *&VDContext);
888 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
894 StringRef internString(StringRef A, StringRef B = StringRef()) {
895 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
897 std::memcpy(
Data, A.data(), A.size());
899 std::memcpy(
Data + A.size(), B.data(), B.size());
900 return StringRef(
Data, A.size() + B.size());
905 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *Method)
const;