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::MDNode *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);
352 llvm::DIType *createFieldType(StringRef name,
QualType type,
354 uint64_t offsetInBits, uint32_t AlignInBits,
355 llvm::DIFile *tunit, llvm::DIScope *scope,
357 llvm::DINodeArray Annotations =
nullptr);
359 llvm::DIType *createFieldType(StringRef name,
QualType type,
361 uint64_t offsetInBits, llvm::DIFile *tunit,
362 llvm::DIScope *scope,
364 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
369 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
370 llvm::DIScope *RecordTy,
371 const RecordDecl *RD);
375 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
376 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
380 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
384 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
385 llvm::DIFile *FileScope);
389 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
390 SmallVectorImpl<llvm::Metadata *> &E,
391 llvm::DIType *RecordTy);
392 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
393 llvm::DIType *RecordTy,
394 const RecordDecl *RD);
395 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
397 SmallVectorImpl<llvm::Metadata *> &E,
398 llvm::DIType *RecordTy,
const RecordDecl *RD);
399 void CollectRecordNestedType(
const TypeDecl *RD,
400 SmallVectorImpl<llvm::Metadata *> &E);
401 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
402 SmallVectorImpl<llvm::Metadata *> &E,
403 llvm::DICompositeType *RecordTy);
404 llvm::StringRef GetLambdaCaptureName(
const LambdaCapture &
Capture);
408 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
409 SmallVectorImpl<llvm::Metadata *> &EltTys);
413 void CreateLexicalBlock(SourceLocation Loc);
421 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
422 SmallVectorImpl<uint64_t> &Expr)
const;
428 uint64_t collectDefaultElementTypesForBlockPointer(
429 const BlockPointerType *Ty, llvm::DIFile *Unit,
430 llvm::DIDerivedType *DescTy,
unsigned LineNo,
431 SmallVectorImpl<llvm::Metadata *> &EltTys);
435 void collectDefaultFieldsForBlockLiteralDeclare(
436 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
437 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
438 SmallVectorImpl<llvm::Metadata *> &Fields);
451 SizeExprCache[Ty] = SizeExpr;
480 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
502 llvm::Function *Fn,
bool CurFnIsThunk);
512 QualType FnType, llvm::Function *Fn =
nullptr);
535 llvm::DILocalVariable *
538 const bool UsePointerValue =
false);
547 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
551 llvm::DILocalVariable *
553 CGBuilderTy &Builder,
bool UsePointerValue =
false);
558 StringRef Name,
unsigned ArgNo,
559 llvm::AllocaInst *LocalAddr,
636 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
647 return CoroutineParameterMappings;
660 StringRef FailureMsg);
668 llvm::DISubprogram *SynthSubprogram);
670 StringRef SynthFuncName,
671 llvm::DIFile *SynthFile);
679 llvm::Value *Backup);
684 llvm::Value *Backup, uint64_t Atom);
701 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
707 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
708 std::optional<unsigned> ArgNo,
710 const bool UsePointerValue =
false);
715 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
716 std::optional<unsigned> ArgNo,
718 const bool UsePointerValue =
false);
720 struct BlockByRefType {
722 llvm::DIType *BlockByRefWrapper;
724 llvm::DIType *WrappedType;
729 bool *NameIsSimplified =
nullptr)
const;
732 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
736 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
738 llvm::DIScope *getContextDescriptor(
const Decl *Context,
741 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
744 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
748 StringRef getCurrentDirname();
751 void CreateCompileUnit();
754 std::optional<llvm::DIFile::ChecksumKind>
767 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
768 std::optional<StringRef> Source);
771 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
776 bool CreateSkeletonCU);
779 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
783 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
786 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
789 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
790 StringRef Name, uint64_t *Offset);
794 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
798 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
807 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
808 unsigned LineNo, llvm::DINode::DIFlags Flags,
809 llvm::DISubprogram::DISPFlags SPFlags);
815 llvm::DIDerivedType *
816 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
819 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
823 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
827 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
831 llvm::DIGlobalVariable *
832 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
841 llvm::DIGlobalVariableExpression *
842 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
843 unsigned LineNo, StringRef LinkageName,
844 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
853 bool *NameIsSimplified =
nullptr);
861 StringRef getSelectorName(
Selector S);
865 bool *NameIsSimplified =
nullptr);
872 StringRef getDynamicInitializerName(
const VarDecl *VD,
874 llvm::Function *InitFn);
887 CurLocFile =
nullptr;
894 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
895 StringRef &Name, StringRef &LinkageName,
896 llvm::DIScope *&FDContext,
897 llvm::DINodeArray &TParamsArray,
898 llvm::DINode::DIFlags &Flags);
901 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
902 unsigned &LineNo, QualType &T, StringRef &Name,
903 StringRef &LinkageName,
904 llvm::MDTuple *&TemplateParameters,
905 llvm::DIScope *&VDContext);
909 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
915 StringRef internString(StringRef A, StringRef B = StringRef()) {
916 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
918 std::memcpy(
Data, A.data(), A.size());
920 std::memcpy(
Data + A.size(), B.data(), B.size());
921 return StringRef(
Data, A.size() + B.size());
926 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *
Method)
const;
929 bool shouldGenerateVirtualCallSite()
const;