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;
110 llvm::DenseMap<const FieldDecl *, unsigned> FieldIndexCache;
114 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
122 std::string remapPath(StringRef Path)
const override {
123 return Self.remapDIPath(Path);
126 PrintingCallbacks PrintCB = {*
this};
128 struct ObjCInterfaceCacheEntry {
129 const ObjCInterfaceType *Type;
132 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
134 : Type(Type), Decl(Decl), Unit(Unit) {}
138 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
143 llvm::DenseMap<
const ObjCInterfaceDecl *,
144 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
148 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
151 std::vector<void *> RetainedTypes;
154 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
158 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
162 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
163 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
167 std::vector<unsigned> FnBeginRegionCount;
171 llvm::BumpPtrAllocator DebugInfoNames;
173 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
174 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
178 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
179 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
180 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
181 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
183 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
184 StaticDataMemberCache;
186 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
187 using Param2DILocTy =
188 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
191 ParamDecl2StmtTy CoroutineParameterMappings;
193 Param2DILocTy ParamDbgMappings;
202 } KeyInstructionsInfo;
211 llvm::DIType *CreateType(
const BitIntType *Ty);
212 llvm::DIType *CreateType(
const OverflowBehaviorType *Ty, llvm::DIFile *
U);
213 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
216 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
217 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
220 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
222 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
223 llvm::DIType *CreateType(
const HLSLAttributedResourceType *Ty,
225 llvm::DIType *CreateType(
const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
227 llvm::DIType *CreateType(
const RecordType *Tyg);
235 std::pair<llvm::DIType *, llvm::DIType *>
236 CreateTypeDefinition(
const RecordType *Ty);
237 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
239 llvm::DICompositeType *CT);
245 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
246 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
248 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
250 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
254 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
255 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
257 llvm::DIType *CreateEnumType(
const EnumType *Ty);
258 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
265 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
270 llvm::DIType *getTypeOrNull(
const QualType);
278 llvm::DISubroutineType *
282 llvm::DISubroutineType *
284 llvm::DIFile *Unit,
bool SkipFirst =
false);
285 llvm::DISubroutineType *
286 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
288 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
291 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
292 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
293 QualType PointeeTy, llvm::DIFile *F);
294 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
300 llvm::DIType *RecordTy);
314 llvm::DIType *RecordTy);
318 void CollectCXXBasesAux(
323 llvm::DINode::DIFlags StartingFlags);
331 struct TemplateArgs {
336 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
340 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
345 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
354 llvm::DINodeArray CollectCXXTemplateParams(
const RecordDecl *TS,
358 llvm::DINodeArray CollectBTFDeclTagAnnotations(
const Decl *D);
363 CollectBTFDeclTagAnnotations(
const Decl *D,
369 CollectBTFTypeTagAnnotations(
QualType Ty,
372 llvm::DIType *createFieldType(StringRef name,
QualType type,
374 uint64_t offsetInBits,
uint32_t AlignInBits,
375 llvm::DIFile *tunit, llvm::DIScope *scope,
377 llvm::DINodeArray Annotations =
nullptr);
379 llvm::DIType *createFieldType(StringRef name,
QualType type,
381 uint64_t offsetInBits, llvm::DIFile *tunit,
382 llvm::DIScope *scope,
384 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
389 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
390 llvm::DIScope *RecordTy,
391 const RecordDecl *RD);
395 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
396 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
400 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
404 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
405 llvm::DIFile *FileScope);
409 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
410 SmallVectorImpl<llvm::Metadata *> &E,
411 llvm::DIType *RecordTy);
412 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
413 llvm::DIType *RecordTy,
414 const RecordDecl *RD);
415 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
417 SmallVectorImpl<llvm::Metadata *> &E,
418 llvm::DIType *RecordTy,
const RecordDecl *RD);
419 void CollectRecordNestedType(
const TypeDecl *RD,
420 SmallVectorImpl<llvm::Metadata *> &E);
421 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
422 SmallVectorImpl<llvm::Metadata *> &E,
423 llvm::DICompositeType *RecordTy);
424 llvm::StringRef GetLambdaCaptureName(
const LambdaCapture &
Capture);
428 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
429 SmallVectorImpl<llvm::Metadata *> &EltTys);
433 void CreateLexicalBlock(SourceLocation Loc);
441 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
442 SmallVectorImpl<uint64_t> &Expr)
const;
448 uint64_t collectDefaultElementTypesForBlockPointer(
449 const BlockPointerType *Ty, llvm::DIFile *Unit,
450 llvm::DIDerivedType *DescTy,
unsigned LineNo,
451 SmallVectorImpl<llvm::Metadata *> &EltTys);
455 void collectDefaultFieldsForBlockLiteralDeclare(
456 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
457 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
458 SmallVectorImpl<llvm::Metadata *> &Fields);
471 SizeExprCache[Ty] = SizeExpr;
500 void setInlinedAt(llvm::DILocation *InlinedAt) { CurInlinedAt = InlinedAt; }
522 llvm::Function *Fn,
bool CurFnIsThunk);
532 QualType FnType, llvm::Function *Fn =
nullptr);
555 llvm::DILocalVariable *
558 const bool UsePointerValue =
false);
567 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
571 llvm::DILocalVariable *
573 CGBuilderTy &Builder,
bool UsePointerValue =
false);
578 StringRef Name,
unsigned ArgNo,
579 llvm::AllocaInst *LocalAddr,
634 std::pair<llvm::DIType *, unsigned>
658 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
669 return CoroutineParameterMappings;
682 StringRef FailureMsg);
690 llvm::DISubprogram *SynthSubprogram);
692 StringRef SynthFuncName,
693 llvm::DIFile *SynthFile);
701 llvm::Value *Backup);
706 llvm::Value *Backup, uint64_t Atom);
723 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
729 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
730 std::optional<unsigned> ArgNo,
732 const bool UsePointerValue =
false);
737 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
738 std::optional<unsigned> ArgNo,
740 const bool UsePointerValue =
false);
742 struct BlockByRefType {
744 llvm::DIType *BlockByRefWrapper;
746 llvm::DIType *WrappedType;
751 bool *NameIsSimplified =
nullptr)
const;
754 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
758 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
760 llvm::DIScope *getContextDescriptor(
const Decl *Context,
763 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
766 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
770 StringRef getCurrentDirname();
773 void CreateCompileUnit();
776 std::optional<llvm::DIFile::ChecksumKind>
789 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
790 std::optional<StringRef> Source);
793 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
798 bool CreateSkeletonCU);
801 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
805 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
808 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
811 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
812 StringRef Name, uint64_t *Offset);
816 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
820 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
829 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
830 unsigned LineNo, llvm::DINode::DIFlags Flags,
831 llvm::DISubprogram::DISPFlags SPFlags);
837 llvm::DIDerivedType *
838 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
841 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
845 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
849 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
853 llvm::DIGlobalVariable *
854 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
863 llvm::DIGlobalVariableExpression *
864 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
865 unsigned LineNo, StringRef LinkageName,
866 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
875 bool *NameIsSimplified =
nullptr);
883 StringRef getSelectorName(
Selector S);
887 bool *NameIsSimplified =
nullptr);
894 StringRef getDynamicInitializerName(
const VarDecl *VD,
896 llvm::Function *InitFn);
909 CurLocFile =
nullptr;
916 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
917 StringRef &Name, StringRef &LinkageName,
918 llvm::DIScope *&FDContext,
919 llvm::DINodeArray &TParamsArray,
920 llvm::DINode::DIFlags &Flags);
923 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
924 unsigned &LineNo, QualType &T, StringRef &Name,
925 StringRef &LinkageName,
926 llvm::MDTuple *&TemplateParameters,
927 llvm::DIScope *&VDContext);
931 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
937 StringRef internString(StringRef A, StringRef B = StringRef()) {
938 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
940 std::memcpy(
Data, A.data(), A.size());
942 std::memcpy(
Data + A.size(), B.data(), B.size());
943 return StringRef(
Data, A.size() + B.size());
948 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *
Method)
const;
951 bool shouldGenerateVirtualCallSite()
const;