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 llvm::SmallDenseMap<llvm::StringRef, llvm::StringRef> DebugPrefixMap;
90 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
92 struct ObjCInterfaceCacheEntry {
93 const ObjCInterfaceType *
Type;
96 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
98 : Type(Type), Decl(Decl), Unit(Unit) {}
105 llvm::DenseMap<const ObjCInterfaceDecl *, std::vector<llvm::DISubprogram *>>
109 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
112 std::vector<void *> RetainedTypes;
115 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
119 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
123 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
124 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
128 std::vector<unsigned> FnBeginRegionCount;
132 llvm::BumpPtrAllocator DebugInfoNames;
135 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
136 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
139 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPDefCache;
140 llvm::DenseMap<const ParmVarDecl *, llvm::TrackingMDRef> ParamCache;
143 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
144 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
145 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
147 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
148 StaticDataMemberCache;
154 llvm::DIType *CreateType(
const BuiltinType *Ty);
155 llvm::DIType *CreateType(
const ComplexType *Ty);
156 llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
157 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
158 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
160 llvm::DIType *CreateType(
const ObjCObjectPointerType *Ty, llvm::DIFile *F);
161 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
162 llvm::DIType *CreateType(
const BlockPointerType *Ty, llvm::DIFile *F);
163 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
165 llvm::DIType *CreateType(
const RecordType *Tyg);
166 llvm::DIType *CreateTypeDefinition(
const RecordType *Ty);
167 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
168 void CollectContainingType(
const CXXRecordDecl *RD,
169 llvm::DICompositeType *CT);
171 llvm::DIType *CreateType(
const ObjCInterfaceType *Ty, llvm::DIFile *F);
172 llvm::DIType *CreateTypeDefinition(
const ObjCInterfaceType *Ty,
175 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
176 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
178 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
179 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
180 llvm::DIType *CreateType(
const LValueReferenceType *Ty, llvm::DIFile *F);
181 llvm::DIType *CreateType(
const RValueReferenceType *Ty, llvm::DIFile *Unit);
182 llvm::DIType *CreateType(
const MemberPointerType *Ty, llvm::DIFile *F);
183 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
184 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
186 llvm::DIType *CreateEnumType(
const EnumType *Ty);
187 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
194 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
199 llvm::DIType *getTypeOrNull(
const QualType);
204 llvm::DISubroutineType *getOrCreateMethodType(
const CXXMethodDecl *Method,
206 llvm::DISubroutineType *
207 getOrCreateInstanceMethodType(QualType ThisPtr,
const FunctionProtoType *Func,
209 llvm::DISubroutineType *
210 getOrCreateFunctionType(
const Decl *D, QualType FnType, llvm::DIFile *F);
212 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
215 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
216 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
217 QualType PointeeTy, llvm::DIFile *F);
218 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
222 llvm::DISubprogram *CreateCXXMemberFunction(
const CXXMethodDecl *Method,
224 llvm::DIType *RecordTy);
229 void CollectCXXMemberFunctions(
const CXXRecordDecl *Decl, llvm::DIFile *F,
230 SmallVectorImpl<llvm::Metadata *> &E,
236 void CollectCXXBases(
const CXXRecordDecl *Decl, llvm::DIFile *F,
237 SmallVectorImpl<llvm::Metadata *> &EltTys,
238 llvm::DIType *RecordTy);
242 void CollectCXXBasesAux(
243 const CXXRecordDecl *RD, llvm::DIFile *Unit,
244 SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType *RecordTy,
245 const CXXRecordDecl::base_class_const_range &Bases,
247 llvm::DINode::DIFlags StartingFlags);
250 llvm::DINodeArray CollectTemplateParams(
const TemplateParameterList *TPList,
251 ArrayRef<TemplateArgument> TAList,
255 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
260 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
266 CollectCXXTemplateParams(
const ClassTemplateSpecializationDecl *TS,
269 llvm::DIType *createFieldType(StringRef
name, QualType
type,
271 uint64_t offsetInBits, uint32_t AlignInBits,
272 llvm::DIFile *tunit, llvm::DIScope *scope,
273 const RecordDecl *RD =
nullptr);
275 llvm::DIType *createFieldType(StringRef name, QualType type,
277 uint64_t offsetInBits, llvm::DIFile *tunit,
278 llvm::DIScope *scope,
279 const RecordDecl *RD =
nullptr) {
280 return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope,
285 llvm::DIType *createBitFieldType(
const FieldDecl *BitFieldDecl,
286 llvm::DIScope *RecordTy,
287 const RecordDecl *RD);
291 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
292 SmallVectorImpl<llvm::Metadata *> &E,
293 llvm::DIType *RecordTy);
294 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
295 llvm::DIType *RecordTy,
296 const RecordDecl *RD);
297 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
299 SmallVectorImpl<llvm::Metadata *> &E,
300 llvm::DIType *RecordTy,
const RecordDecl *RD);
301 void CollectRecordNestedType(
const TypeDecl *RD,
302 SmallVectorImpl<llvm::Metadata *> &E);
303 void CollectRecordFields(
const RecordDecl *Decl, llvm::DIFile *F,
304 SmallVectorImpl<llvm::Metadata *> &E,
305 llvm::DICompositeType *RecordTy);
309 void CollectVTableInfo(
const CXXRecordDecl *Decl, llvm::DIFile *F,
310 SmallVectorImpl<llvm::Metadata *> &EltTys,
311 llvm::DICompositeType *RecordTy);
315 void CreateLexicalBlock(SourceLocation Loc);
323 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
324 SmallVectorImpl<int64_t> &Expr)
const;
330 uint64_t collectDefaultElementTypesForBlockPointer(
331 const BlockPointerType *Ty, llvm::DIFile *Unit,
332 llvm::DIDerivedType *DescTy,
unsigned LineNo,
333 SmallVectorImpl<llvm::Metadata *> &EltTys);
337 void collectDefaultFieldsForBlockLiteralDeclare(
338 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
339 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
340 SmallVectorImpl<llvm::Metadata *> &Fields);
343 CGDebugInfo(CodeGenModule &CGM);
349 std::string remapDIPath(StringRef)
const;
353 SizeExprCache[Ty] = SizeExpr;
359 void setDwoId(uint64_t Signature);
384 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
403 llvm::Function *Fn,
bool CurFnIsThunk,
414 QualType FnType, llvm::Function *Fn =
nullptr);
418 void EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
423 void EmitFunctionEnd(
CGBuilderTy &Builder, llvm::Function *Fn);
437 llvm::DILocalVariable *
440 const bool UsePointerValue =
false);
447 void EmitDeclareOfBlockDeclRefVariable(
449 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
458 void EmitDeclareOfBlockLiteralArgVariable(
const CGBlockInfo &block,
459 StringRef Name,
unsigned ArgNo,
460 llvm::AllocaInst *LocalAddr,
464 void EmitGlobalVariable(llvm::GlobalVariable *GV,
const VarDecl *Decl);
473 void EmitExplicitCastType(
QualType Ty);
494 void addHeapAllocSiteMetadata(llvm::Instruction *CallSite,
QualType Ty,
497 void completeType(
const EnumDecl *ED);
499 void completeRequiredType(
const RecordDecl *RD);
508 llvm::DIMacro *CreateMacro(llvm::DIMacroFile *
Parent,
unsigned MType,
513 llvm::DIMacroFile *CreateTempMacroFile(llvm::DIMacroFile *Parent,
524 const bool UsePointerValue =
false);
526 struct BlockByRefType {
528 llvm::DIType *BlockByRefWrapper;
530 llvm::DIType *WrappedType;
534 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
538 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
540 llvm::DIScope *getContextDescriptor(
const Decl *Context,
543 llvm::DIScope *getCurrentContextDescriptor(
const Decl *Decl);
546 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
550 StringRef getCurrentDirname();
553 void CreateCompileUnit();
569 Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
573 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
579 bool CreateSkeletonCU);
582 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
586 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty,
590 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
593 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
594 StringRef Name, uint64_t *
Offset);
598 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
602 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
608 llvm::DIDerivedType *
609 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
612 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
616 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
620 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
624 llvm::DIGlobalVariable *
625 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
634 llvm::DIGlobalVariableExpression *
635 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
636 unsigned LineNo, StringRef LinkageName,
637 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
642 llvm::DINode::DIFlags getCallSiteRelatedAttrs()
const;
658 StringRef getSelectorName(
Selector S);
668 StringRef getDynamicInitializerName(
const VarDecl *VD,
670 llvm::Function *InitFn);
683 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
684 StringRef &Name, StringRef &LinkageName,
685 llvm::DIScope *&FDContext,
686 llvm::DINodeArray &TParamsArray,
687 llvm::DINode::DIFlags &Flags);
690 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
691 unsigned &LineNo,
QualType &T, StringRef &Name,
692 StringRef &LinkageName,
693 llvm::MDTuple *&TemplateParameters,
694 llvm::DIScope *&VDContext);
699 StringRef internString(StringRef A, StringRef B = StringRef()) {
700 char *Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
705 return StringRef(Data, A.size() + B.size());
713 void init(
SourceLocation TemporaryLocation,
bool DefaultToEmpty =
false);
717 llvm::DebugLoc OriginalLocation;
781 #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.
static json::Object createFile(const FileEntry &FE)
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.
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.