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 *OCLReserveIDDITy =
nullptr;
88#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
89 llvm::DIType *Id##Ty = nullptr;
90#include "clang/Basic/OpenCLExtensionTypes.def"
91#define WASM_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
92#include "clang/Basic/WebAssemblyReferenceTypes.def"
93#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
94 llvm::DIType *SingletonId = nullptr;
95#include "clang/Basic/AMDGPUTypes.def"
96#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
97 llvm::DIType *SingletonId = nullptr;
98#include "clang/Basic/HLSLIntangibleTypes.def"
99#define SPIRV_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
100#include "clang/Basic/SPIRVTypes.def"
103 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
106 llvm::DenseMap<const FieldDecl *, unsigned> FieldIndexCache;
110 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
118 std::string remapPath(StringRef Path)
const override {
119 return Self.remapDIPath(Path);
122 PrintingCallbacks PrintCB = {*
this};
124 struct ObjCInterfaceCacheEntry {
125 const ObjCInterfaceType *Type;
128 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
130 : Type(Type), Decl(Decl), Unit(Unit) {}
134 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
139 llvm::DenseMap<
const ObjCInterfaceDecl *,
140 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
144 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
147 std::vector<void *> RetainedTypes;
150 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
154 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
158 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
161 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIScope>>
164 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
168 std::vector<unsigned> FnBeginRegionCount;
172 llvm::BumpPtrAllocator DebugInfoNames;
174 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
176 struct DIFileSource {
184 llvm::DenseMap<const llvm::DIFile *, DIFileSource> DIFileSources;
185 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
189 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
190 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
191 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
192 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
194 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
195 StaticDataMemberCache;
197 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
198 using Param2DILocTy =
199 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
202 ParamDecl2StmtTy CoroutineParameterMappings;
204 Param2DILocTy ParamDbgMappings;
213 } KeyInstructionsInfo;
222 llvm::DIType *CreateType(
const BitIntType *Ty);
223 llvm::DIType *CreateType(
const OverflowBehaviorType *Ty, llvm::DIFile *
U);
224 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
227 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
228 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
231 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
233 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
234 llvm::DIType *CreateType(
const HLSLAttributedResourceType *Ty,
236 llvm::DIType *CreateType(
const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
238 llvm::DIType *CreateType(
const RecordType *Tyg);
246 std::pair<llvm::DIType *, llvm::DIType *>
247 CreateTypeDefinition(
const RecordType *Ty);
248 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
250 llvm::DICompositeType *CT);
256 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
257 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
259 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
262 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
266 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
267 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
269 llvm::DIType *CreateEnumType(
const EnumType *Ty);
270 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
277 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
282 llvm::DIType *getTypeOrNull(
const QualType);
290 llvm::DISubroutineType *
294 llvm::DISubroutineType *
296 llvm::DIFile *Unit,
bool SkipFirst =
false);
297 llvm::DISubroutineType *
298 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
300 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
303 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
304 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
305 QualType PointeeTy, llvm::DIFile *F);
306 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
312 llvm::DIType *RecordTy);
326 llvm::DIType *RecordTy);
330 void CollectCXXBasesAux(
335 llvm::DINode::DIFlags StartingFlags);
343 struct TemplateArgs {
348 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
352 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
357 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
366 llvm::DINodeArray CollectCXXTemplateParams(
const RecordDecl *TS,
370 llvm::DINodeArray CollectBTFDeclTagAnnotations(
const Decl *D);
375 CollectBTFDeclTagAnnotations(
const Decl *D,
381 CollectBTFTypeTagAnnotations(
QualType Ty,
384 llvm::DIType *createFieldType(StringRef name,
QualType type,
387 llvm::DIFile *tunit, llvm::DIScope *scope,
389 llvm::DINodeArray Annotations =
nullptr);
391 llvm::DIType *createFieldType(StringRef name,
QualType type,
393 uint64_t offsetInBits, llvm::DIFile *tunit,
394 llvm::DIScope *scope,
396 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
401 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
402 llvm::DIScope *RecordTy,
403 const RecordDecl *RD);
407 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
408 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
412 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
416 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
417 llvm::DIFile *FileScope);
421 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
422 SmallVectorImpl<llvm::Metadata *> &E,
423 llvm::DIType *RecordTy);
424 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
425 llvm::DIType *RecordTy,
426 const RecordDecl *RD);
429 SmallVectorImpl<llvm::Metadata *> &E,
430 llvm::DIType *RecordTy,
const RecordDecl *RD);
431 void CollectRecordNestedType(
const TypeDecl *RD,
432 SmallVectorImpl<llvm::Metadata *> &E);
433 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
434 SmallVectorImpl<llvm::Metadata *> &E,
435 llvm::DICompositeType *RecordTy);
436 llvm::StringRef GetLambdaCaptureName(
const LambdaCapture &
Capture);
440 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
441 SmallVectorImpl<llvm::Metadata *> &EltTys);
445 void CreateLexicalBlock(SourceLocation Loc);
453 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
454 SmallVectorImpl<uint64_t> &Expr)
const;
460 uint64_t collectDefaultElementTypesForBlockPointer(
461 const BlockPointerType *Ty, llvm::DIFile *Unit,
462 llvm::DIDerivedType *DescTy,
unsigned LineNo,
463 SmallVectorImpl<llvm::Metadata *> &EltTys);
467 void collectDefaultFieldsForBlockLiteralDeclare(
468 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
469 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
470 SmallVectorImpl<llvm::Metadata *> &Fields);
483 SizeExprCache[Ty] = SizeExpr;
512 void setInlinedAt(llvm::DILocation *InlinedAt) { CurInlinedAt = InlinedAt; }
534 llvm::Function *Fn,
bool CurFnIsThunk);
544 QualType FnType, llvm::Function *Fn =
nullptr);
567 llvm::DILocalVariable *
570 const bool UsePointerValue =
false);
579 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
583 llvm::DILocalVariable *
585 CGBuilderTy &Builder,
bool UsePointerValue =
false);
590 StringRef Name,
unsigned ArgNo,
591 llvm::AllocaInst *LocalAddr,
616 llvm::DenseMap<const llvm::DIFile *, OptionalFileEntryRef>
653 std::pair<llvm::DIType *, unsigned>
683 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
694 return CoroutineParameterMappings;
707 StringRef FailureMsg);
715 llvm::DISubprogram *SynthSubprogram);
717 StringRef SynthFuncName,
718 llvm::DIFile *SynthFile);
726 llvm::Value *Backup);
731 llvm::Value *Backup,
uint64_t Atom);
748 void addInstSourceAtomMetadata(llvm::Instruction *I,
uint64_t Group,
754 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
755 std::optional<unsigned> ArgNo,
757 const bool UsePointerValue =
false);
762 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
763 std::optional<unsigned> ArgNo,
765 const bool UsePointerValue =
false);
767 struct BlockByRefType {
769 llvm::DIType *BlockByRefWrapper;
771 llvm::DIType *WrappedType;
776 bool *NameIsSimplified =
nullptr)
const;
779 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
783 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
785 llvm::DIScope *getContextDescriptor(
const Decl *Context,
788 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
791 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
795 StringRef getCurrentDirname();
798 void CreateCompileUnit();
801 std::optional<llvm::DIFile::ChecksumKind>
812 void recordDIFileSource(
const llvm::DIFile *F,
FileID FID);
817 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
818 std::optional<StringRef> Source);
821 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
826 bool CreateSkeletonCU);
829 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
833 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
836 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
839 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
844 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
848 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
857 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
858 unsigned LineNo, llvm::DINode::DIFlags Flags,
859 llvm::DISubprogram::DISPFlags SPFlags);
865 llvm::DIDerivedType *
866 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
869 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
873 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
877 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
881 llvm::DIGlobalVariable *
882 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
891 llvm::DIGlobalVariableExpression *
892 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
893 unsigned LineNo, StringRef LinkageName,
894 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
903 bool *NameIsSimplified =
nullptr);
911 StringRef getSelectorName(
Selector S);
915 bool *NameIsSimplified =
nullptr);
922 StringRef getDynamicInitializerName(
const VarDecl *VD,
924 llvm::Function *InitFn);
937 CurLocFile =
nullptr;
944 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
945 StringRef &Name, StringRef &LinkageName,
946 llvm::DIScope *&FDContext,
947 llvm::DINodeArray &TParamsArray,
948 llvm::DINode::DIFlags &Flags);
951 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
952 unsigned &LineNo, QualType &T, StringRef &Name,
953 StringRef &LinkageName,
954 llvm::MDTuple *&TemplateParameters,
955 llvm::DIScope *&VDContext);
959 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
965 StringRef internString(StringRef A, StringRef B = StringRef()) {
966 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
968 std::memcpy(
Data, A.data(), A.size());
970 std::memcpy(
Data + A.size(), B.data(), B.size());
971 return StringRef(
Data, A.size() + B.size());
976 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *
Method)
const;
979 bool shouldGenerateVirtualCallSite()
const;