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"
102 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
106 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
114 std::string remapPath(StringRef Path)
const override {
115 return Self.remapDIPath(Path);
118 PrintingCallbacks PrintCB = {*
this};
120 struct ObjCInterfaceCacheEntry {
121 const ObjCInterfaceType *Type;
124 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
126 : Type(Type), Decl(Decl), Unit(Unit) {}
130 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
135 llvm::DenseMap<
const ObjCInterfaceDecl *,
136 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
140 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
143 std::vector<void *> RetainedTypes;
146 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
150 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
154 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
155 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
159 std::vector<unsigned> FnBeginRegionCount;
163 llvm::BumpPtrAllocator DebugInfoNames;
165 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
166 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
170 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
171 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
172 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
173 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
175 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
176 StaticDataMemberCache;
178 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
179 using Param2DILocTy =
180 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
183 ParamDecl2StmtTy CoroutineParameterMappings;
185 Param2DILocTy ParamDbgMappings;
194 } KeyInstructionsInfo;
203 llvm::DIType *CreateType(
const BitIntType *Ty);
204 llvm::DIType *CreateType(
const OverflowBehaviorType *Ty, llvm::DIFile *
U);
205 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
208 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
209 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
212 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
214 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
215 llvm::DIType *CreateType(
const HLSLAttributedResourceType *Ty,
217 llvm::DIType *CreateType(
const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
219 llvm::DIType *CreateType(
const RecordType *Tyg);
227 std::pair<llvm::DIType *, llvm::DIType *>
228 CreateTypeDefinition(
const RecordType *Ty);
229 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
231 llvm::DICompositeType *CT);
237 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
238 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
240 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
242 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
246 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
247 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
249 llvm::DIType *CreateEnumType(
const EnumType *Ty);
250 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
257 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
262 llvm::DIType *getTypeOrNull(
const QualType);
270 llvm::DISubroutineType *
274 llvm::DISubroutineType *
276 llvm::DIFile *Unit,
bool SkipFirst =
false);
277 llvm::DISubroutineType *
278 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
280 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
283 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
284 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
285 QualType PointeeTy, llvm::DIFile *F);
286 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
292 llvm::DIType *RecordTy);
306 llvm::DIType *RecordTy);
310 void CollectCXXBasesAux(
315 llvm::DINode::DIFlags StartingFlags);
323 struct TemplateArgs {
328 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
332 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
337 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
346 llvm::DINodeArray CollectCXXTemplateParams(
const RecordDecl *TS,
350 llvm::DINodeArray CollectBTFDeclTagAnnotations(
const Decl *D);
355 CollectBTFDeclTagAnnotations(
const Decl *D,
361 CollectBTFTypeTagAnnotations(
QualType Ty,
364 llvm::DIType *createFieldType(StringRef name,
QualType type,
366 uint64_t offsetInBits,
uint32_t AlignInBits,
367 llvm::DIFile *tunit, llvm::DIScope *scope,
369 llvm::DINodeArray Annotations =
nullptr);
371 llvm::DIType *createFieldType(StringRef name,
QualType type,
373 uint64_t offsetInBits, llvm::DIFile *tunit,
374 llvm::DIScope *scope,
376 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
381 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
382 llvm::DIScope *RecordTy,
383 const RecordDecl *RD);
387 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
388 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
392 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
396 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
397 llvm::DIFile *FileScope);
401 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
402 SmallVectorImpl<llvm::Metadata *> &E,
403 llvm::DIType *RecordTy);
404 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
405 llvm::DIType *RecordTy,
406 const RecordDecl *RD);
407 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
409 SmallVectorImpl<llvm::Metadata *> &E,
410 llvm::DIType *RecordTy,
const RecordDecl *RD);
411 void CollectRecordNestedType(
const TypeDecl *RD,
412 SmallVectorImpl<llvm::Metadata *> &E);
413 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
414 SmallVectorImpl<llvm::Metadata *> &E,
415 llvm::DICompositeType *RecordTy);
416 llvm::StringRef GetLambdaCaptureName(
const LambdaCapture &
Capture);
420 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
421 SmallVectorImpl<llvm::Metadata *> &EltTys);
425 void CreateLexicalBlock(SourceLocation Loc);
433 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
434 SmallVectorImpl<uint64_t> &Expr)
const;
440 uint64_t collectDefaultElementTypesForBlockPointer(
441 const BlockPointerType *Ty, llvm::DIFile *Unit,
442 llvm::DIDerivedType *DescTy,
unsigned LineNo,
443 SmallVectorImpl<llvm::Metadata *> &EltTys);
447 void collectDefaultFieldsForBlockLiteralDeclare(
448 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
449 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
450 SmallVectorImpl<llvm::Metadata *> &Fields);
463 SizeExprCache[Ty] = SizeExpr;
492 void setInlinedAt(llvm::DILocation *InlinedAt) { CurInlinedAt = InlinedAt; }
514 llvm::Function *Fn,
bool CurFnIsThunk);
524 QualType FnType, llvm::Function *Fn =
nullptr);
547 llvm::DILocalVariable *
550 const bool UsePointerValue =
false);
559 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
563 llvm::DILocalVariable *
565 CGBuilderTy &Builder,
bool UsePointerValue =
false);
570 StringRef Name,
unsigned ArgNo,
571 llvm::AllocaInst *LocalAddr,
648 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
659 return CoroutineParameterMappings;
672 StringRef FailureMsg);
680 llvm::DISubprogram *SynthSubprogram);
682 StringRef SynthFuncName,
683 llvm::DIFile *SynthFile);
691 llvm::Value *Backup);
696 llvm::Value *Backup, uint64_t Atom);
713 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
719 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
720 std::optional<unsigned> ArgNo,
722 const bool UsePointerValue =
false);
727 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
728 std::optional<unsigned> ArgNo,
730 const bool UsePointerValue =
false);
732 struct BlockByRefType {
734 llvm::DIType *BlockByRefWrapper;
736 llvm::DIType *WrappedType;
741 bool *NameIsSimplified =
nullptr)
const;
744 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
748 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
750 llvm::DIScope *getContextDescriptor(
const Decl *Context,
753 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
756 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
760 StringRef getCurrentDirname();
763 void CreateCompileUnit();
766 std::optional<llvm::DIFile::ChecksumKind>
779 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
780 std::optional<StringRef> Source);
783 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
788 bool CreateSkeletonCU);
791 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
795 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
798 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
801 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
802 StringRef Name, uint64_t *Offset);
806 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
810 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
819 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
820 unsigned LineNo, llvm::DINode::DIFlags Flags,
821 llvm::DISubprogram::DISPFlags SPFlags);
827 llvm::DIDerivedType *
828 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
831 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
835 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
839 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
843 llvm::DIGlobalVariable *
844 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
853 llvm::DIGlobalVariableExpression *
854 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
855 unsigned LineNo, StringRef LinkageName,
856 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
865 bool *NameIsSimplified =
nullptr);
873 StringRef getSelectorName(
Selector S);
877 bool *NameIsSimplified =
nullptr);
884 StringRef getDynamicInitializerName(
const VarDecl *VD,
886 llvm::Function *InitFn);
899 CurLocFile =
nullptr;
906 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
907 StringRef &Name, StringRef &LinkageName,
908 llvm::DIScope *&FDContext,
909 llvm::DINodeArray &TParamsArray,
910 llvm::DINode::DIFlags &Flags);
913 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
914 unsigned &LineNo, QualType &T, StringRef &Name,
915 StringRef &LinkageName,
916 llvm::MDTuple *&TemplateParameters,
917 llvm::DIScope *&VDContext);
921 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
927 StringRef internString(StringRef A, StringRef B = StringRef()) {
928 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
930 std::memcpy(
Data, A.data(), A.size());
932 std::memcpy(
Data + A.size(), B.data(), B.size());
933 return StringRef(
Data, A.size() + B.size());
938 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *
Method)
const;
941 bool shouldGenerateVirtualCallSite()
const;