65 const llvm::codegenoptions::DebugInfoKind DebugKind;
66 bool DebugTypeExtRefs;
67 llvm::DIBuilder DBuilder;
68 llvm::DICompileUnit *TheCU =
nullptr;
72 llvm::MDNode *CurInlinedAt =
nullptr;
73 llvm::DIType *VTablePtrType =
nullptr;
74 llvm::DIType *ClassTy =
nullptr;
75 llvm::DICompositeType *ObjTy =
nullptr;
76 llvm::DIType *SelTy =
nullptr;
77#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
78 llvm::DIType *SingletonId = nullptr;
79#include "clang/Basic/OpenCLImageTypes.def"
80 llvm::DIType *OCLSamplerDITy =
nullptr;
81 llvm::DIType *OCLEventDITy =
nullptr;
82 llvm::DIType *OCLClkEventDITy =
nullptr;
83 llvm::DIType *OCLQueueDITy =
nullptr;
84 llvm::DIType *OCLNDRangeDITy =
nullptr;
85 llvm::DIType *OCLReserveIDDITy =
nullptr;
86#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
87 llvm::DIType *Id##Ty = nullptr;
88#include "clang/Basic/OpenCLExtensionTypes.def"
89#define WASM_TYPE(Name, Id, SingletonId) llvm::DIType *SingletonId = nullptr;
90#include "clang/Basic/WebAssemblyReferenceTypes.def"
91#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
92 llvm::DIType *SingletonId = nullptr;
93#include "clang/Basic/AMDGPUTypes.def"
94#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
95 llvm::DIType *SingletonId = nullptr;
96#include "clang/Basic/HLSLIntangibleTypes.def"
99 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
103 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
111 std::string remapPath(StringRef Path)
const override {
112 return Self.remapDIPath(Path);
115 PrintingCallbacks PrintCB = {*
this};
117 struct ObjCInterfaceCacheEntry {
118 const ObjCInterfaceType *Type;
121 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
123 : Type(Type), Decl(Decl), Unit(Unit) {}
127 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
132 llvm::DenseMap<
const ObjCInterfaceDecl *,
133 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
137 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
140 std::vector<void *> RetainedTypes;
143 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
147 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
151 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
152 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
156 std::vector<unsigned> FnBeginRegionCount;
160 llvm::BumpPtrAllocator DebugInfoNames;
162 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
163 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
167 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
168 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> ImportedDeclCache;
169 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
170 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
172 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
173 StaticDataMemberCache;
175 using ParamDecl2StmtTy = llvm::DenseMap<const ParmVarDecl *, const Stmt *>;
176 using Param2DILocTy =
177 llvm::DenseMap<const ParmVarDecl *, llvm::DILocalVariable *>;
180 ParamDecl2StmtTy CoroutineParameterMappings;
182 Param2DILocTy ParamDbgMappings;
191 } KeyInstructionsInfo;
200 llvm::DIType *CreateType(
const BitIntType *Ty);
201 llvm::DIType *CreateType(
const OverflowBehaviorType *Ty, llvm::DIFile *
U);
202 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
205 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
206 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
209 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
211 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
212 llvm::DIType *CreateType(
const HLSLAttributedResourceType *Ty,
214 llvm::DIType *CreateType(
const HLSLInlineSpirvType *Ty, llvm::DIFile *F);
216 llvm::DIType *CreateType(
const RecordType *Tyg);
224 std::pair<llvm::DIType *, llvm::DIType *>
225 CreateTypeDefinition(
const RecordType *Ty);
226 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
228 llvm::DICompositeType *CT);
234 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
235 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
237 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
239 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
243 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
244 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
246 llvm::DIType *CreateEnumType(
const EnumType *Ty);
247 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
254 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
259 llvm::DIType *getTypeOrNull(
const QualType);
267 llvm::DISubroutineType *
271 llvm::DISubroutineType *
273 llvm::DIFile *Unit,
bool SkipFirst =
false);
274 llvm::DISubroutineType *
275 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
277 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
280 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
281 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
282 QualType PointeeTy, llvm::DIFile *F);
283 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
289 llvm::DIType *RecordTy);
303 llvm::DIType *RecordTy);
307 void CollectCXXBasesAux(
312 llvm::DINode::DIFlags StartingFlags);
320 struct TemplateArgs {
325 llvm::DINodeArray CollectTemplateParams(std::optional<TemplateArgs> Args,
329 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
334 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
343 llvm::DINodeArray CollectCXXTemplateParams(
const RecordDecl *TS,
347 llvm::DINodeArray CollectBTFDeclTagAnnotations(
const Decl *D);
349 llvm::DIType *createFieldType(StringRef name,
QualType type,
351 uint64_t offsetInBits, uint32_t AlignInBits,
352 llvm::DIFile *tunit, llvm::DIScope *scope,
354 llvm::DINodeArray Annotations =
nullptr);
356 llvm::DIType *createFieldType(StringRef name,
QualType type,
358 uint64_t offsetInBits, llvm::DIFile *tunit,
359 llvm::DIScope *scope,
361 return createFieldType(name,
type, loc, AS, offsetInBits, 0, tunit, scope,
366 llvm::DIDerivedType *createBitFieldType(
const FieldDecl *BitFieldDecl,
367 llvm::DIScope *RecordTy,
368 const RecordDecl *RD);
372 llvm::DIDerivedType *createBitFieldSeparatorIfNeeded(
373 const FieldDecl *BitFieldDecl,
const llvm::DIDerivedType *BitFieldDI,
377 llvm::StringMap<llvm::DISubprogram *> InlinedSubprogramMap;
381 llvm::DISubprogram *createInlinedSubprogram(StringRef FuncName,
382 llvm::DIFile *FileScope);
386 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
387 SmallVectorImpl<llvm::Metadata *> &E,
388 llvm::DIType *RecordTy);
389 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
390 llvm::DIType *RecordTy,
391 const RecordDecl *RD);
392 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
394 SmallVectorImpl<llvm::Metadata *> &E,
395 llvm::DIType *RecordTy,
const RecordDecl *RD);
396 void CollectRecordNestedType(
const TypeDecl *RD,
397 SmallVectorImpl<llvm::Metadata *> &E);
398 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
399 SmallVectorImpl<llvm::Metadata *> &E,
400 llvm::DICompositeType *RecordTy);
401 llvm::StringRef GetLambdaCaptureName(
const LambdaCapture &
Capture);
405 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
406 SmallVectorImpl<llvm::Metadata *> &EltTys);
410 void CreateLexicalBlock(SourceLocation Loc);
418 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
419 SmallVectorImpl<uint64_t> &Expr)
const;
425 uint64_t collectDefaultElementTypesForBlockPointer(
426 const BlockPointerType *Ty, llvm::DIFile *Unit,
427 llvm::DIDerivedType *DescTy,
unsigned LineNo,
428 SmallVectorImpl<llvm::Metadata *> &EltTys);
432 void collectDefaultFieldsForBlockLiteralDeclare(
433 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
434 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
435 SmallVectorImpl<llvm::Metadata *> &Fields);
448 SizeExprCache[Ty] = SizeExpr;
477 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
499 llvm::Function *Fn,
bool CurFnIsThunk);
509 QualType FnType, llvm::Function *Fn =
nullptr);
532 llvm::DILocalVariable *
535 const bool UsePointerValue =
false);
544 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
548 llvm::DILocalVariable *
550 CGBuilderTy &Builder,
bool UsePointerValue =
false);
555 StringRef Name,
unsigned ArgNo,
556 llvm::AllocaInst *LocalAddr,
633 llvm::DIMacro *
CreateMacro(llvm::DIMacroFile *Parent,
unsigned MType,
644 return CoroutineParameterMappings;
657 StringRef FailureMsg);
672 llvm::Value *Backup);
677 llvm::Value *Backup, uint64_t Atom);
691 void addInstSourceAtomMetadata(llvm::Instruction *I, uint64_t Group,
697 llvm::DILocalVariable *EmitDeclare(
const VarDecl *
decl, llvm::Value *AI,
698 std::optional<unsigned> ArgNo,
700 const bool UsePointerValue =
false);
705 llvm::DILocalVariable *EmitDeclare(
const BindingDecl *
decl, llvm::Value *AI,
706 std::optional<unsigned> ArgNo,
708 const bool UsePointerValue =
false);
710 struct BlockByRefType {
712 llvm::DIType *BlockByRefWrapper;
714 llvm::DIType *WrappedType;
719 bool *NameIsSimplified =
nullptr)
const;
722 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
726 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
728 llvm::DIScope *getContextDescriptor(
const Decl *Context,
731 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
734 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
738 StringRef getCurrentDirname();
741 void CreateCompileUnit();
744 std::optional<llvm::DIFile::ChecksumKind>
757 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
758 std::optional<StringRef> Source);
761 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
766 bool CreateSkeletonCU);
769 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
773 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty);
776 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
779 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
780 StringRef Name, uint64_t *Offset);
784 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
788 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
797 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
798 unsigned LineNo, llvm::DINode::DIFlags Flags,
799 llvm::DISubprogram::DISPFlags SPFlags);
805 llvm::DIDerivedType *
806 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
809 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
813 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
817 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
821 llvm::DIGlobalVariable *
822 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
831 llvm::DIGlobalVariableExpression *
832 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
833 unsigned LineNo, StringRef LinkageName,
834 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
843 bool *NameIsSimplified =
nullptr);
851 StringRef getSelectorName(
Selector S);
855 bool *NameIsSimplified =
nullptr);
862 StringRef getDynamicInitializerName(
const VarDecl *VD,
864 llvm::Function *InitFn);
877 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
878 StringRef &Name, StringRef &LinkageName,
879 llvm::DIScope *&FDContext,
880 llvm::DINodeArray &TParamsArray,
881 llvm::DINode::DIFlags &Flags);
884 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
885 unsigned &LineNo,
QualType &T, StringRef &Name,
886 StringRef &LinkageName,
887 llvm::MDTuple *&TemplateParameters,
888 llvm::DIScope *&VDContext);
892 llvm::DIExpression *createConstantValueExpression(
const clang::ValueDecl *VD,
898 StringRef internString(StringRef A, StringRef B = StringRef()) {
899 char *
Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
901 std::memcpy(
Data, A.data(), A.size());
903 std::memcpy(
Data + A.size(), B.data(), B.size());
904 return StringRef(
Data, A.size() + B.size());
909 llvm::StringRef GetMethodLinkageName(
const CXXMethodDecl *Method)
const;