13 #ifndef LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H 14 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H 24 #include "llvm/ADT/DenseMap.h" 25 #include "llvm/ADT/DenseSet.h" 26 #include "llvm/ADT/Optional.h" 27 #include "llvm/IR/DIBuilder.h" 28 #include "llvm/IR/DebugInfo.h" 29 #include "llvm/IR/ValueHandle.h" 30 #include "llvm/Support/Allocator.h" 37 class ClassTemplateSpecializationDecl;
40 class ObjCInterfaceDecl;
48 class CodeGenFunction;
56 friend class SaveAndRestoreLocation;
59 bool DebugTypeExtRefs;
60 llvm::DIBuilder DBuilder;
61 llvm::DICompileUnit *TheCU =
nullptr;
65 llvm::MDNode *CurInlinedAt =
nullptr;
66 llvm::DIType *VTablePtrType =
nullptr;
67 llvm::DIType *ClassTy =
nullptr;
68 llvm::DICompositeType *ObjTy =
nullptr;
69 llvm::DIType *SelTy =
nullptr;
70 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 71 llvm::DIType *SingletonId = nullptr; 72 #include "clang/Basic/OpenCLImageTypes.def" 73 llvm::DIType *OCLSamplerDITy =
nullptr;
74 llvm::DIType *OCLEventDITy =
nullptr;
75 llvm::DIType *OCLClkEventDITy =
nullptr;
76 llvm::DIType *OCLQueueDITy =
nullptr;
77 llvm::DIType *OCLNDRangeDITy =
nullptr;
78 llvm::DIType *OCLReserveIDDITy =
nullptr;
79 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 80 llvm::DIType *Id##Ty = nullptr; 81 #include "clang/Basic/OpenCLExtensionTypes.def" 84 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
86 std::map<llvm::StringRef, llvm::StringRef, std::greater<llvm::StringRef>>
91 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
95 const CGDebugInfo &Self;
98 PrintingCallbacks(
const CGDebugInfo &Self) : Self(Self) {}
99 std::string remapPath(StringRef Path)
const override {
100 return Self.remapDIPath(Path);
103 PrintingCallbacks PrintCB = {*
this};
105 struct ObjCInterfaceCacheEntry {
106 const ObjCInterfaceType *
Type;
109 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
111 : Type(Type), Decl(Decl), Unit(Unit) {}
120 llvm::DenseMap<
const ObjCInterfaceDecl *,
121 std::vector<llvm::PointerIntPair<llvm::DISubprogram *, 1>>>
125 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
128 std::vector<void *> RetainedTypes;
131 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
135 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
139 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
140 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
144 std::vector<unsigned> FnBeginRegionCount;
148 llvm::BumpPtrAllocator DebugInfoNames;
151 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
152 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
155 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
156 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
157 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
159 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
160 StaticDataMemberCache;
166 llvm::DIType *CreateType(
const BuiltinType *Ty);
167 llvm::DIType *CreateType(
const ComplexType *Ty);
168 llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
169 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
170 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
172 llvm::DIType *CreateType(
const ObjCObjectPointerType *Ty, llvm::DIFile *F);
173 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
174 llvm::DIType *CreateType(
const BlockPointerType *Ty, llvm::DIFile *F);
175 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
177 llvm::DIType *CreateType(
const RecordType *Tyg);
178 llvm::DIType *CreateTypeDefinition(
const RecordType *Ty);
179 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
180 void CollectContainingType(
const CXXRecordDecl *RD,
181 llvm::DICompositeType *CT);
183 llvm::DIType *CreateType(
const ObjCInterfaceType *Ty, llvm::DIFile *F);
184 llvm::DIType *CreateTypeDefinition(
const ObjCInterfaceType *Ty,
187 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
188 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
190 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
191 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
192 llvm::DIType *CreateType(
const LValueReferenceType *Ty, llvm::DIFile *F);
193 llvm::DIType *CreateType(
const RValueReferenceType *Ty, llvm::DIFile *Unit);
194 llvm::DIType *CreateType(
const MemberPointerType *Ty, llvm::DIFile *F);
195 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
196 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
198 llvm::DIType *CreateEnumType(
const EnumType *Ty);
199 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
206 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
211 llvm::DIType *getTypeOrNull(
const QualType);
216 llvm::DISubroutineType *getOrCreateMethodType(
const CXXMethodDecl *Method,
218 llvm::DISubroutineType *
219 getOrCreateInstanceMethodType(QualType ThisPtr,
const FunctionProtoType *Func,
221 llvm::DISubroutineType *
222 getOrCreateFunctionType(
const Decl *D, QualType FnType, llvm::DIFile *F);
224 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
227 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
228 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
229 QualType PointeeTy, llvm::DIFile *F);
230 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
234 llvm::DISubprogram *CreateCXXMemberFunction(
const CXXMethodDecl *Method,
236 llvm::DIType *RecordTy);
241 void CollectCXXMemberFunctions(
const CXXRecordDecl *Decl, llvm::DIFile *F,
242 SmallVectorImpl<llvm::Metadata *> &E,
248 void CollectCXXBases(
const CXXRecordDecl *Decl, llvm::DIFile *F,
249 SmallVectorImpl<llvm::Metadata *> &EltTys,
250 llvm::DIType *RecordTy);
254 void CollectCXXBasesAux(
255 const CXXRecordDecl *RD, llvm::DIFile *Unit,
256 SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType *RecordTy,
257 const CXXRecordDecl::base_class_const_range &Bases,
259 llvm::DINode::DIFlags StartingFlags);
262 llvm::DINodeArray CollectTemplateParams(
const TemplateParameterList *TPList,
263 ArrayRef<TemplateArgument> TAList,
267 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
272 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
278 CollectCXXTemplateParams(
const ClassTemplateSpecializationDecl *TS,
281 llvm::DIType *createFieldType(StringRef
name, QualType
type,
283 uint64_t offsetInBits, uint32_t AlignInBits,
284 llvm::DIFile *tunit, llvm::DIScope *scope,
285 const RecordDecl *RD =
nullptr);
287 llvm::DIType *createFieldType(StringRef name, QualType type,
289 uint64_t offsetInBits, llvm::DIFile *tunit,
290 llvm::DIScope *scope,
291 const RecordDecl *RD =
nullptr) {
292 return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope,
297 llvm::DIType *createBitFieldType(
const FieldDecl *BitFieldDecl,
298 llvm::DIScope *RecordTy,
299 const RecordDecl *RD);
303 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
304 SmallVectorImpl<llvm::Metadata *> &E,
305 llvm::DIType *RecordTy);
306 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
307 llvm::DIType *RecordTy,
308 const RecordDecl *RD);
309 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
311 SmallVectorImpl<llvm::Metadata *> &E,
312 llvm::DIType *RecordTy,
const RecordDecl *RD);
313 void CollectRecordNestedType(
const TypeDecl *RD,
314 SmallVectorImpl<llvm::Metadata *> &E);
315 void CollectRecordFields(
const RecordDecl *Decl, llvm::DIFile *F,
316 SmallVectorImpl<llvm::Metadata *> &E,
317 llvm::DICompositeType *RecordTy);
321 void CollectVTableInfo(
const CXXRecordDecl *Decl, llvm::DIFile *F,
322 SmallVectorImpl<llvm::Metadata *> &EltTys,
323 llvm::DICompositeType *RecordTy);
327 void CreateLexicalBlock(SourceLocation Loc);
335 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
336 SmallVectorImpl<int64_t> &Expr)
const;
342 uint64_t collectDefaultElementTypesForBlockPointer(
343 const BlockPointerType *Ty, llvm::DIFile *Unit,
344 llvm::DIDerivedType *DescTy,
unsigned LineNo,
345 SmallVectorImpl<llvm::Metadata *> &EltTys);
349 void collectDefaultFieldsForBlockLiteralDeclare(
350 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
351 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
352 SmallVectorImpl<llvm::Metadata *> &Fields);
355 CGDebugInfo(CodeGenModule &CGM);
361 std::string remapDIPath(StringRef)
const;
365 SizeExprCache[Ty] = SizeExpr;
371 void setDwoId(uint64_t Signature);
396 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
415 llvm::Function *Fn,
bool CurFnIsThunk,
426 QualType FnType, llvm::Function *Fn =
nullptr);
430 void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
435 void EmitFunctionEnd(
CGBuilderTy &Builder, llvm::Function *Fn);
449 llvm::DILocalVariable *
452 const bool UsePointerValue =
false);
459 void EmitDeclareOfBlockDeclRefVariable(
461 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
470 void EmitDeclareOfBlockLiteralArgVariable(
const CGBlockInfo &block,
471 StringRef Name,
unsigned ArgNo,
472 llvm::AllocaInst *LocalAddr,
476 void EmitGlobalVariable(llvm::GlobalVariable *GV,
const VarDecl *Decl);
482 void EmitExternalVariable(llvm::GlobalVariable *GV,
const VarDecl *Decl);
488 void EmitExplicitCastType(
QualType Ty);
509 void addHeapAllocSiteMetadata(llvm::Instruction *CallSite,
QualType Ty,
512 void completeType(
const EnumDecl *ED);
514 void completeRequiredType(
const RecordDecl *RD);
523 llvm::DIMacro *CreateMacro(llvm::DIMacroFile *
Parent,
unsigned MType,
528 llvm::DIMacroFile *CreateTempMacroFile(llvm::DIMacroFile *Parent,
539 const bool UsePointerValue =
false);
541 struct BlockByRefType {
543 llvm::DIType *BlockByRefWrapper;
545 llvm::DIType *WrappedType;
549 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
553 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
555 llvm::DIScope *getContextDescriptor(
const Decl *Context,
558 llvm::DIScope *getCurrentContextDescriptor(
const Decl *Decl);
561 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
565 StringRef getCurrentDirname();
568 void CreateCompileUnit();
583 createFile(StringRef FileName,
584 Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
588 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
594 bool CreateSkeletonCU);
597 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
601 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty,
605 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
608 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
609 StringRef Name, uint64_t *
Offset);
613 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
617 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
626 getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType,
627 unsigned LineNo, llvm::DINode::DIFlags Flags,
628 llvm::DISubprogram::DISPFlags SPFlags);
634 llvm::DIDerivedType *
635 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
638 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
642 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
646 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
650 llvm::DIGlobalVariable *
651 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
660 llvm::DIGlobalVariableExpression *
661 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
662 unsigned LineNo, StringRef LinkageName,
663 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
668 llvm::DINode::DIFlags getCallSiteRelatedAttrs()
const;
684 StringRef getSelectorName(
Selector S);
694 StringRef getDynamicInitializerName(
const VarDecl *VD,
696 llvm::Function *InitFn);
709 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
710 StringRef &Name, StringRef &LinkageName,
711 llvm::DIScope *&FDContext,
712 llvm::DINodeArray &TParamsArray,
713 llvm::DINode::DIFlags &Flags);
716 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
717 unsigned &LineNo,
QualType &T, StringRef &Name,
718 StringRef &LinkageName,
719 llvm::MDTuple *&TemplateParameters,
720 llvm::DIScope *&VDContext);
725 StringRef internString(StringRef A, StringRef B = StringRef()) {
726 char *Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
731 return StringRef(Data, A.size() + B.size());
739 void init(
SourceLocation TemporaryLocation,
bool DefaultToEmpty =
false);
743 llvm::DebugLoc OriginalLocation;
808 #endif // LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
Represents a function declaration or definition.
llvm::MDNode * getInlinedAt() const
Smart pointer class that efficiently represents Objective-C method names.
void EmitLocation(raw_ostream &o, const SourceManager &SM, SourceLocation L, const FIDMap &FM, unsigned indent)
A (possibly-)qualified type.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
C Language Family Type Representation.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
void finalize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
void setPCHDescriptor(ExternalASTSource::ASTSourceDescriptor PCH)
When generating debug information for a clang module or precompiled header, this module map will be u...
Represents a variable declaration or definition.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
ObjCMethodDecl - Represents an instance or class method declaration.
Describes how types, statements, expressions, and declarations should be printed. ...
void setInlinedAt(llvm::MDNode *InlinedAt)
Update the current inline scope.
Represents a struct/union/class.
Represents a class template specialization, which refers to a class template with a given set of temp...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF)
Apply TemporaryLocation if it is valid.
Represents a C++ using-declaration.
void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr)
Register VLA size expression debug node with the qualified type.
CGBlockInfo - Information to generate a block literal.
Allows QualTypes to be sorted and hence used in maps and sets.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
A scoped helper to set the current debug location to an inlined location.
GlobalDecl - represents a global declaration.
Encodes a location in the source.
Represents the declaration of a label.
A scoped helper to set the current debug location to the specified location or preferred location of ...
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Describes a module import declaration, which makes the contents of the named module visible in the cu...
SourceLocation getLocation() const
Return the current source location.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
This class organizes the cross-function state that is used while generating LLVM code.
Optional< types::ID > Type
Dataflow Directional Tag Classes.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
Callbacks to use to customize the behavior of the pretty-printer.
void setModuleMap(ModuleMap &MMap)
When generating debug information for a clang module or precompiled header, this module map will be u...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
ApplyDebugLocation(ApplyDebugLocation &&Other)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Set the IRBuilder to not attach debug locations.
Represents a C++ namespace alias.
Represents C++ using-directive.
This class handles loading and caching of source files into memory.