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 SPIRV_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
101#include "clang/Basic/SPIRVTypes.def"
104 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
108 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
116 std::string remapPath(StringRef Path)
const override {
117 return Self.remapDIPath(Path);
120 PrintingCallbacks PrintCB = {*
this};
122 struct ObjCInterfaceCacheEntry {
123 const ObjCInterfaceType *Type;
126 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
128 : Type(Type), Decl(Decl), Unit(Unit) {}
132 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
137 llvm::DenseMap<
const ObjCInterfaceDecl *,
138 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
142 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
145 std::vector<void *> RetainedTypes;
148 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
152 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
156 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
157 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
161 std::vector<unsigned> FnBeginRegionCount;
165 llvm::BumpPtrAllocator DebugInfoNames;
167 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
168 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
172 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
173 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
174 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
175 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
177 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
178 StaticDataMemberCache;
180 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
181 using Param2DILocTy =
182 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
185 ParamDecl2StmtTy CoroutineParameterMappings;
187 Param2DILocTy ParamDbgMappings;
196 } KeyInstructionsInfo;
205 llvm::DIType *CreateType(
const BitIntType *Ty);
206 llvm::DIType *CreateType(
const OverflowBehaviorType *Ty, llvm::DIFile *
U);
207 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
210 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
211 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
214 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
216 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
217 llvm::DIType *CreateType(
const HLSLAttributedResourceType *Ty,
219 llvm::DIType *CreateType(
const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
221 llvm::DIType *CreateType(
const RecordType *Tyg);
229 std::pair<llvm::DIType *, llvm::DIType *>
230 CreateTypeDefinition(
const RecordType *Ty);
231 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
233 llvm::DICompositeType *CT);
239 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
240 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
242 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
244 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
248 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
249 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
251 llvm::DIType *CreateEnumType(
const EnumType *Ty);
252 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
259 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
264 llvm::DIType *getTypeOrNull(
const QualType);
272 llvm::DISubroutineType *
276 llvm::DISubroutineType *
278 llvm::DIFile *Unit,
bool SkipFirst =
false);
279 llvm::DISubroutineType *
280 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
282 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
285 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
286 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
287 QualType PointeeTy, llvm::DIFile *F);
288 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
294 llvm::DIType *RecordTy);
308 llvm::DIType *RecordTy);
312 void CollectCXXBasesAux(
317 llvm::DINode::DIFlags StartingFlags);
325 struct TemplateArgs {
330 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
334 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
339 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
348 llvm::DINodeArray CollectCXXTemplateParams(
const RecordDecl *TS,
352 llvm::DINodeArray CollectBTFDeclTagAnnotations(
const Decl *D);
357 CollectBTFDeclTagAnnotations(
const Decl *D,
363 CollectBTFTypeTagAnnotations(
QualType Ty,
366 llvm::DIType *createFieldType(StringRef name,
QualType type,
368 uint64_t offsetInBits,
uint32_t AlignInBits,
369 llvm::DIFile *tunit, llvm::DIScope *scope,
371 llvm::DINodeArray Annotations =
nullptr);
373 llvm::DIType *createFieldType(StringRef name,
QualType type,
375 uint64_t offsetInBits, llvm::DIFile *tunit,
376 llvm::DIScope *scope,
378 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
383 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
384 llvm::DIScope *RecordTy,
385 const RecordDecl *RD);
389 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
390 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
394 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
398 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
399 llvm::DIFile *FileScope);
403 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
404 SmallVectorImpl<llvm::Metadata *> &E,
405 llvm::DIType *RecordTy);
406 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
407 llvm::DIType *RecordTy,
408 const RecordDecl *RD);
409 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
411 SmallVectorImpl<llvm::Metadata *> &E,
412 llvm::DIType *RecordTy,
const RecordDecl *RD);
413 void CollectRecordNestedType(
const TypeDecl *RD,
414 SmallVectorImpl<llvm::Metadata *> &E);
415 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
416 SmallVectorImpl<llvm::Metadata *> &E,
417 llvm::DICompositeType *RecordTy);
418 llvm::StringRef GetLambdaCaptureName(
const LambdaCapture &
Capture);
422 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
423 SmallVectorImpl<llvm::Metadata *> &EltTys);
427 void CreateLexicalBlock(SourceLocation Loc);
435 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
436 SmallVectorImpl<uint64_t> &Expr)
const;
442 uint64_t collectDefaultElementTypesForBlockPointer(
443 const BlockPointerType *Ty, llvm::DIFile *Unit,
444 llvm::DIDerivedType *DescTy,
unsigned LineNo,
445 SmallVectorImpl<llvm::Metadata *> &EltTys);
449 void collectDefaultFieldsForBlockLiteralDeclare(
450 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
451 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
452 SmallVectorImpl<llvm::Metadata *> &Fields);
465 SizeExprCache[Ty] = SizeExpr;
494 void setInlinedAt(llvm::DILocation *InlinedAt) { CurInlinedAt = InlinedAt; }
516 llvm::Function *Fn,
bool CurFnIsThunk);
526 QualType FnType, llvm::Function *Fn =
nullptr);
549 llvm::DILocalVariable *
552 const bool UsePointerValue =
false);
561 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
565 llvm::DILocalVariable *
567 CGBuilderTy &Builder,
bool UsePointerValue =
false);
572 StringRef Name,
unsigned ArgNo,
573 llvm::AllocaInst *LocalAddr,
650 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
661 return CoroutineParameterMappings;
674 StringRef FailureMsg);
682 llvm::DISubprogram *SynthSubprogram);
684 StringRef SynthFuncName,
685 llvm::DIFile *SynthFile);
693 llvm::Value *Backup);
698 llvm::Value *Backup, uint64_t Atom);
715 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
721 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
722 std::optional<unsigned> ArgNo,
724 const bool UsePointerValue =
false);
729 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
730 std::optional<unsigned> ArgNo,
732 const bool UsePointerValue =
false);
734 struct BlockByRefType {
736 llvm::DIType *BlockByRefWrapper;
738 llvm::DIType *WrappedType;
743 bool *NameIsSimplified =
nullptr)
const;
746 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
750 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
752 llvm::DIScope *getContextDescriptor(
const Decl *Context,
755 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
758 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
762 StringRef getCurrentDirname();
765 void CreateCompileUnit();
768 std::optional<llvm::DIFile::ChecksumKind>
781 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
782 std::optional<StringRef> Source);
785 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
790 bool CreateSkeletonCU);
793 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
797 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
800 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
803 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
804 StringRef Name, uint64_t *Offset);
808 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
812 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
821 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
822 unsigned LineNo, llvm::DINode::DIFlags Flags,
823 llvm::DISubprogram::DISPFlags SPFlags);
829 llvm::DIDerivedType *
830 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
833 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
837 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
841 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
845 llvm::DIGlobalVariable *
846 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
855 llvm::DIGlobalVariableExpression *
856 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
857 unsigned LineNo, StringRef LinkageName,
858 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
867 bool *NameIsSimplified =
nullptr);
875 StringRef getSelectorName(
Selector S);
879 bool *NameIsSimplified =
nullptr);
886 StringRef getDynamicInitializerName(
const VarDecl *VD,
888 llvm::Function *InitFn);
901 CurLocFile =
nullptr;
908 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
909 StringRef &Name, StringRef &LinkageName,
910 llvm::DIScope *&FDContext,
911 llvm::DINodeArray &TParamsArray,
912 llvm::DINode::DIFlags &Flags);
915 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
916 unsigned &LineNo, QualType &T, StringRef &Name,
917 StringRef &LinkageName,
918 llvm::MDTuple *&TemplateParameters,
919 llvm::DIScope *&VDContext);
923 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
929 StringRef internString(StringRef A, StringRef B = StringRef()) {
930 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
932 std::memcpy(
Data, A.data(), A.size());
934 std::memcpy(
Data + A.size(), B.data(), B.size());
935 return StringRef(
Data, A.size() + B.size());
940 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *
Method)
const;
943 bool shouldGenerateVirtualCallSite()
const;