14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H 15 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H 25 #include "llvm/ADT/DenseMap.h" 26 #include "llvm/ADT/DenseSet.h" 27 #include "llvm/ADT/Optional.h" 28 #include "llvm/IR/DIBuilder.h" 29 #include "llvm/IR/DebugInfo.h" 30 #include "llvm/IR/ValueHandle.h" 31 #include "llvm/Support/Allocator.h" 38 class ClassTemplateSpecializationDecl;
41 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 Decl *, llvm::TrackingMDRef> DeclCache;
140 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
141 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
143 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
144 StaticDataMemberCache;
150 llvm::DIType *CreateType(
const BuiltinType *Ty);
151 llvm::DIType *CreateType(
const ComplexType *Ty);
152 llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
153 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
154 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
156 llvm::DIType *CreateType(
const ObjCObjectPointerType *Ty, llvm::DIFile *F);
157 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
158 llvm::DIType *CreateType(
const BlockPointerType *Ty, llvm::DIFile *F);
159 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
161 llvm::DIType *CreateType(
const RecordType *Tyg);
162 llvm::DIType *CreateTypeDefinition(
const RecordType *Ty);
163 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
164 void CollectContainingType(
const CXXRecordDecl *RD,
165 llvm::DICompositeType *CT);
167 llvm::DIType *CreateType(
const ObjCInterfaceType *Ty, llvm::DIFile *F);
168 llvm::DIType *CreateTypeDefinition(
const ObjCInterfaceType *Ty,
171 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
172 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
174 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
175 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
176 llvm::DIType *CreateType(
const LValueReferenceType *Ty, llvm::DIFile *F);
177 llvm::DIType *CreateType(
const RValueReferenceType *Ty, llvm::DIFile *Unit);
178 llvm::DIType *CreateType(
const MemberPointerType *Ty, llvm::DIFile *F);
179 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
180 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
182 llvm::DIType *CreateEnumType(
const EnumType *Ty);
183 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
190 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
195 llvm::DIType *getTypeOrNull(
const QualType);
200 llvm::DISubroutineType *getOrCreateMethodType(
const CXXMethodDecl *Method,
202 llvm::DISubroutineType *
203 getOrCreateInstanceMethodType(QualType ThisPtr,
const FunctionProtoType *Func,
205 llvm::DISubroutineType *
206 getOrCreateFunctionType(
const Decl *D, QualType FnType, llvm::DIFile *F);
208 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
211 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
212 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
213 QualType PointeeTy, llvm::DIFile *F);
214 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
218 llvm::DISubprogram *CreateCXXMemberFunction(
const CXXMethodDecl *Method,
220 llvm::DIType *RecordTy);
225 void CollectCXXMemberFunctions(
const CXXRecordDecl *Decl, llvm::DIFile *F,
226 SmallVectorImpl<llvm::Metadata *> &E,
232 void CollectCXXBases(
const CXXRecordDecl *Decl, llvm::DIFile *F,
233 SmallVectorImpl<llvm::Metadata *> &EltTys,
234 llvm::DIType *RecordTy);
238 void CollectCXXBasesAux(
239 const CXXRecordDecl *RD, llvm::DIFile *Unit,
240 SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType *RecordTy,
241 const CXXRecordDecl::base_class_const_range &Bases,
243 llvm::DINode::DIFlags StartingFlags);
246 llvm::DINodeArray CollectTemplateParams(
const TemplateParameterList *TPList,
247 ArrayRef<TemplateArgument> TAList,
251 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
256 llvm::DINodeArray CollectVarTemplateParams(
const VarDecl *VD,
262 CollectCXXTemplateParams(
const ClassTemplateSpecializationDecl *TS,
265 llvm::DIType *createFieldType(StringRef name, QualType
type,
267 uint64_t offsetInBits, uint32_t AlignInBits,
268 llvm::DIFile *tunit, llvm::DIScope *scope,
269 const RecordDecl *RD =
nullptr);
271 llvm::DIType *createFieldType(StringRef name, QualType type,
273 uint64_t offsetInBits, llvm::DIFile *tunit,
274 llvm::DIScope *scope,
275 const RecordDecl *RD =
nullptr) {
276 return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope,
281 llvm::DIType *createBitFieldType(
const FieldDecl *BitFieldDecl,
282 llvm::DIScope *RecordTy,
283 const RecordDecl *RD);
287 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
288 SmallVectorImpl<llvm::Metadata *> &E,
289 llvm::DIType *RecordTy);
290 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
291 llvm::DIType *RecordTy,
292 const RecordDecl *RD);
293 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
295 SmallVectorImpl<llvm::Metadata *> &E,
296 llvm::DIType *RecordTy,
const RecordDecl *RD);
297 void CollectRecordNestedType(
const TypeDecl *RD,
298 SmallVectorImpl<llvm::Metadata *> &E);
299 void CollectRecordFields(
const RecordDecl *Decl, llvm::DIFile *F,
300 SmallVectorImpl<llvm::Metadata *> &E,
301 llvm::DICompositeType *RecordTy);
305 void CollectVTableInfo(
const CXXRecordDecl *Decl, llvm::DIFile *F,
306 SmallVectorImpl<llvm::Metadata *> &EltTys,
307 llvm::DICompositeType *RecordTy);
311 void CreateLexicalBlock(SourceLocation Loc);
319 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
320 SmallVectorImpl<int64_t> &Expr)
const;
326 uint64_t collectDefaultElementTypesForBlockPointer(
327 const BlockPointerType *Ty, llvm::DIFile *Unit,
328 llvm::DIDerivedType *DescTy,
unsigned LineNo,
329 SmallVectorImpl<llvm::Metadata *> &EltTys);
333 void collectDefaultFieldsForBlockLiteralDeclare(
334 const CGBlockInfo &Block,
const ASTContext &Context, SourceLocation Loc,
335 const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
336 SmallVectorImpl<llvm::Metadata *> &Fields);
339 CGDebugInfo(CodeGenModule &CGM);
345 std::string remapDIPath(StringRef)
const;
349 SizeExprCache[Ty] = SizeExpr;
355 void setDwoId(uint64_t Signature);
380 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
399 llvm::Function *Fn,
bool CurFnIsThunk,
411 void EmitFunctionEnd(
CGBuilderTy &Builder, llvm::Function *Fn);
425 llvm::DILocalVariable *EmitDeclareOfAutoVariable(
const VarDecl *Decl,
431 void EmitDeclareOfBlockDeclRefVariable(
433 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
442 void EmitDeclareOfBlockLiteralArgVariable(
const CGBlockInfo &block,
443 StringRef Name,
unsigned ArgNo,
444 llvm::AllocaInst *LocalAddr,
448 void EmitGlobalVariable(llvm::GlobalVariable *GV,
const VarDecl *Decl);
457 void EmitExplicitCastType(
QualType Ty);
477 void completeType(
const EnumDecl *ED);
479 void completeRequiredType(
const RecordDecl *RD);
488 llvm::DIMacro *CreateMacro(llvm::DIMacroFile *
Parent,
unsigned MType,
493 llvm::DIMacroFile *CreateTempMacroFile(llvm::DIMacroFile *Parent,
505 struct BlockByRefType {
507 llvm::DIType *BlockByRefWrapper;
509 llvm::DIType *WrappedType;
513 BlockByRefType EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
517 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
519 llvm::DIScope *getContextDescriptor(
const Decl *Context,
522 llvm::DIScope *getCurrentContextDescriptor(
const Decl *Decl);
525 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
529 StringRef getCurrentDirname();
532 void CreateCompileUnit();
548 Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
552 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
558 bool CreateSkeletonCU);
561 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
565 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty,
569 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
572 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
573 StringRef Name, uint64_t *
Offset);
577 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
581 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
587 llvm::DIDerivedType *
588 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
591 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
595 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
599 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
603 llvm::DIGlobalVariable *
604 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
613 llvm::DIGlobalVariableExpression *
614 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
615 unsigned LineNo, StringRef LinkageName,
616 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
621 llvm::DINode::DIFlags getCallSiteRelatedAttrs()
const;
637 StringRef getSelectorName(
Selector S);
656 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
657 StringRef &Name, StringRef &LinkageName,
658 llvm::DIScope *&FDContext,
659 llvm::DINodeArray &TParamsArray,
660 llvm::DINode::DIFlags &Flags);
663 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
664 unsigned &LineNo,
QualType &T, StringRef &Name,
665 StringRef &LinkageName,
666 llvm::MDTuple *&TemplateParameters,
667 llvm::DIScope *&VDContext);
672 StringRef internString(StringRef A, StringRef B = StringRef()) {
673 char *Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
678 return StringRef(Data, A.size() + B.size());
686 void init(
SourceLocation TemporaryLocation,
bool DefaultToEmpty =
false);
690 llvm::DebugLoc OriginalLocation;
754 #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.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
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.