65 const llvm::codegenoptions::DebugInfoKind DebugKind;
66 bool DebugTypeExtRefs;
67 llvm::DIBuilder DBuilder;
68 llvm::DICompileUnit *TheCU =
nullptr;
72 llvm::DIFile *CurLocFile =
nullptr;
73 unsigned CurLocLine = 0;
74 unsigned CurLocColumn = 0;
75 llvm::DILocation *CurInlinedAt =
nullptr;
76 llvm::DIType *VTablePtrType =
nullptr;
77 llvm::DIType *ClassTy =
nullptr;
78 llvm::DICompositeType *ObjTy =
nullptr;
79 llvm::DIType *SelTy =
nullptr;
80#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
81 llvm::DIType *SingletonId = nullptr;
82#include "clang/Basic/OpenCLImageTypes.def"
83 llvm::DIType *OCLSamplerDITy =
nullptr;
84 llvm::DIType *OCLEventDITy =
nullptr;
85 llvm::DIType *OCLClkEventDITy =
nullptr;
86 llvm::DIType *OCLQueueDITy =
nullptr;
87 llvm::DIType *OCLNDRangeDITy =
nullptr;
88 llvm::DIType *OCLReserveIDDITy =
nullptr;
89#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
90 llvm::DIType *Id##Ty = nullptr;
91#include "clang/Basic/OpenCLExtensionTypes.def"
92#define WASM_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
93#include "clang/Basic/WebAssemblyReferenceTypes.def"
94#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
95 llvm::DIType *SingletonId = nullptr;
96#include "clang/Basic/AMDGPUTypes.def"
97#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
98 llvm::DIType *SingletonId = nullptr;
99#include "clang/Basic/HLSLIntangibleTypes.def"
100#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
101 llvm::DIType *SingletonId = nullptr;
102#include "clang/Basic/HLSLPackedTypes.def"
103#define SPIRV_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
104#include "clang/Basic/SPIRVTypes.def"
107 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
111 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
119 std::string remapPath(StringRef Path)
const override {
120 return Self.remapDIPath(Path);
123 PrintingCallbacks PrintCB = {*
this};
125 struct ObjCInterfaceCacheEntry {
126 const ObjCInterfaceType *Type;
129 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
131 : Type(Type), Decl(Decl), Unit(Unit) {}
135 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
140 llvm::DenseMap<
const ObjCInterfaceDecl *,
141 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
145 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
148 std::vector<void *> RetainedTypes;
151 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
155 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
159 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
160 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
164 std::vector<unsigned> FnBeginRegionCount;
168 llvm::BumpPtrAllocator DebugInfoNames;
170 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
171 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
175 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
176 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
177 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
178 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
180 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
181 StaticDataMemberCache;
183 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
184 using Param2DILocTy =
185 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
188 ParamDecl2StmtTy CoroutineParameterMappings;
190 Param2DILocTy ParamDbgMappings;
199 } KeyInstructionsInfo;
208 llvm::DIType *CreateType(
const BitIntType *Ty);
209 llvm::DIType *CreateType(
const OverflowBehaviorType *Ty, llvm::DIFile *
U);
210 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
213 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
214 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
217 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
219 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
220 llvm::DIType *CreateType(
const HLSLAttributedResourceType *Ty,
222 llvm::DIType *CreateType(
const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
224 llvm::DIType *CreateType(
const RecordType *Tyg);
232 std::pair<llvm::DIType *, llvm::DIType *>
233 CreateTypeDefinition(
const RecordType *Ty);
234 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
236 llvm::DICompositeType *CT);
242 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
243 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
245 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
247 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
251 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
252 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
254 llvm::DIType *CreateEnumType(
const EnumType *Ty);
255 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
262 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
267 llvm::DIType *getTypeOrNull(
const QualType);
275 llvm::DISubroutineType *
279 llvm::DISubroutineType *
281 llvm::DIFile *Unit,
bool SkipFirst =
false);
282 llvm::DISubroutineType *
283 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
285 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
288 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
289 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
290 QualType PointeeTy, llvm::DIFile *F);
291 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
297 llvm::DIType *RecordTy);
311 llvm::DIType *RecordTy);
315 void CollectCXXBasesAux(
320 llvm::DINode::DIFlags StartingFlags);
328 struct TemplateArgs {
333 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
337 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
342 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
351 llvm::DINodeArray CollectCXXTemplateParams(
const RecordDecl *TS,
355 llvm::DINodeArray CollectBTFDeclTagAnnotations(
const Decl *D);
360 CollectBTFDeclTagAnnotations(
const Decl *D,
366 CollectBTFTypeTagAnnotations(
QualType Ty,
369 llvm::DIType *createFieldType(StringRef name,
QualType type,
371 uint64_t offsetInBits,
uint32_t AlignInBits,
372 llvm::DIFile *tunit, llvm::DIScope *scope,
374 llvm::DINodeArray Annotations =
nullptr);
376 llvm::DIType *createFieldType(StringRef name,
QualType type,
378 uint64_t offsetInBits, llvm::DIFile *tunit,
379 llvm::DIScope *scope,
381 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
386 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
387 llvm::DIScope *RecordTy,
388 const RecordDecl *RD);
392 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
393 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
397 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
401 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
402 llvm::DIFile *FileScope);
406 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
407 SmallVectorImpl<llvm::Metadata *> &E,
408 llvm::DIType *RecordTy);
409 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
410 llvm::DIType *RecordTy,
411 const RecordDecl *RD);
412 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
414 SmallVectorImpl<llvm::Metadata *> &E,
415 llvm::DIType *RecordTy,
const RecordDecl *RD);
416 void CollectRecordNestedType(
const TypeDecl *RD,
417 SmallVectorImpl<llvm::Metadata *> &E);
418 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
419 SmallVectorImpl<llvm::Metadata *> &E,
420 llvm::DICompositeType *RecordTy);
421 llvm::StringRef GetLambdaCaptureName(
const LambdaCapture &
Capture);
425 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
426 SmallVectorImpl<llvm::Metadata *> &EltTys);
430 void CreateLexicalBlock(SourceLocation Loc);
438 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
439 SmallVectorImpl<uint64_t> &Expr)
const;
445 uint64_t collectDefaultElementTypesForBlockPointer(
446 const BlockPointerType *Ty, llvm::DIFile *Unit,
447 llvm::DIDerivedType *DescTy,
unsigned LineNo,
448 SmallVectorImpl<llvm::Metadata *> &EltTys);
452 void collectDefaultFieldsForBlockLiteralDeclare(
453 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
454 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
455 SmallVectorImpl<llvm::Metadata *> &Fields);
468 SizeExprCache[Ty] = SizeExpr;
497 void setInlinedAt(llvm::DILocation *InlinedAt) { CurInlinedAt = InlinedAt; }
519 llvm::Function *Fn,
bool CurFnIsThunk);
529 QualType FnType, llvm::Function *Fn =
nullptr);
552 llvm::DILocalVariable *
555 const bool UsePointerValue =
false);
564 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
568 llvm::DILocalVariable *
570 CGBuilderTy &Builder,
bool UsePointerValue =
false);
575 StringRef Name,
unsigned ArgNo,
576 llvm::AllocaInst *LocalAddr,
653 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
664 return CoroutineParameterMappings;
677 StringRef FailureMsg);
685 llvm::DISubprogram *SynthSubprogram);
687 StringRef SynthFuncName,
688 llvm::DIFile *SynthFile);
696 llvm::Value *Backup);
701 llvm::Value *Backup, uint64_t Atom);
718 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
724 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
725 std::optional<unsigned> ArgNo,
727 const bool UsePointerValue =
false);
732 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
733 std::optional<unsigned> ArgNo,
735 const bool UsePointerValue =
false);
737 struct BlockByRefType {
739 llvm::DIType *BlockByRefWrapper;
741 llvm::DIType *WrappedType;
746 bool *NameIsSimplified =
nullptr)
const;
749 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
753 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
755 llvm::DIScope *getContextDescriptor(
const Decl *Context,
758 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
761 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
765 StringRef getCurrentDirname();
768 void CreateCompileUnit();
771 std::optional<llvm::DIFile::ChecksumKind>
784 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
785 std::optional<StringRef> Source);
788 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
793 bool CreateSkeletonCU);
796 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
800 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
803 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
806 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
807 StringRef Name, uint64_t *Offset);
811 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
815 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
824 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
825 unsigned LineNo, llvm::DINode::DIFlags Flags,
826 llvm::DISubprogram::DISPFlags SPFlags);
832 llvm::DIDerivedType *
833 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
836 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
840 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
844 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
848 llvm::DIGlobalVariable *
849 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
858 llvm::DIGlobalVariableExpression *
859 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
860 unsigned LineNo, StringRef LinkageName,
861 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
870 bool *NameIsSimplified =
nullptr);
878 StringRef getSelectorName(
Selector S);
882 bool *NameIsSimplified =
nullptr);
889 StringRef getDynamicInitializerName(
const VarDecl *VD,
891 llvm::Function *InitFn);
904 CurLocFile =
nullptr;
911 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
912 StringRef &Name, StringRef &LinkageName,
913 llvm::DIScope *&FDContext,
914 llvm::DINodeArray &TParamsArray,
915 llvm::DINode::DIFlags &Flags);
918 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
919 unsigned &LineNo, QualType &T, StringRef &Name,
920 StringRef &LinkageName,
921 llvm::MDTuple *&TemplateParameters,
922 llvm::DIScope *&VDContext);
926 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
932 StringRef internString(StringRef A, StringRef B = StringRef()) {
933 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
935 std::memcpy(
Data, A.data(), A.size());
937 std::memcpy(
Data + A.size(), B.data(), B.size());
938 return StringRef(
Data, A.size() + B.size());
943 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *
Method)
const;
946 bool shouldGenerateVirtualCallSite()
const;