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;
81 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
83 llvm::SmallDenseMap<llvm::StringRef, llvm::StringRef> DebugPrefixMap;
87 llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache;
89 struct ObjCInterfaceCacheEntry {
90 const ObjCInterfaceType *Type;
93 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *Type, llvm::DIType *Decl,
95 : Type(Type), Decl(Decl), Unit(Unit) {}
102 llvm::DenseMap<const ObjCInterfaceDecl *, std::vector<llvm::DISubprogram *>>
106 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
109 std::vector<void *> RetainedTypes;
112 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
116 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
120 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
121 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
125 std::vector<unsigned> FnBeginRegionCount;
129 llvm::BumpPtrAllocator DebugInfoNames;
132 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
133 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
136 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
137 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NamespaceCache;
138 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
140 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
141 StaticDataMemberCache;
147 llvm::DIType *CreateType(
const BuiltinType *Ty);
148 llvm::DIType *CreateType(
const ComplexType *Ty);
149 llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
150 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
151 llvm::DIType *CreateType(
const TemplateSpecializationType *Ty,
153 llvm::DIType *CreateType(
const ObjCObjectPointerType *Ty, llvm::DIFile *F);
154 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
155 llvm::DIType *CreateType(
const BlockPointerType *Ty, llvm::DIFile *F);
156 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
158 llvm::DIType *CreateType(
const RecordType *Tyg);
159 llvm::DIType *CreateTypeDefinition(
const RecordType *Ty);
160 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
161 void CollectContainingType(
const CXXRecordDecl *RD,
162 llvm::DICompositeType *CT);
164 llvm::DIType *CreateType(
const ObjCInterfaceType *Ty, llvm::DIFile *F);
165 llvm::DIType *CreateTypeDefinition(
const ObjCInterfaceType *Ty,
168 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
169 llvm::DIType *CreateType(
const ObjCTypeParamType *Ty, llvm::DIFile *Unit);
171 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
172 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
173 llvm::DIType *CreateType(
const LValueReferenceType *Ty, llvm::DIFile *F);
174 llvm::DIType *CreateType(
const RValueReferenceType *Ty, llvm::DIFile *Unit);
175 llvm::DIType *CreateType(
const MemberPointerType *Ty, llvm::DIFile *F);
176 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
177 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
179 llvm::DIType *CreateEnumType(
const EnumType *Ty);
180 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
187 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
192 llvm::DIType *getTypeOrNull(
const QualType);
197 llvm::DISubroutineType *getOrCreateMethodType(
const CXXMethodDecl *Method,
199 llvm::DISubroutineType *
200 getOrCreateInstanceMethodType(QualType ThisPtr,
const FunctionProtoType *Func,
202 llvm::DISubroutineType *
203 getOrCreateFunctionType(
const Decl *D, QualType FnType, llvm::DIFile *F);
205 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
208 llvm::DINamespace *getOrCreateNamespace(
const NamespaceDecl *N);
209 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
210 QualType PointeeTy, llvm::DIFile *F);
211 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
215 llvm::DISubprogram *CreateCXXMemberFunction(
const CXXMethodDecl *Method,
217 llvm::DIType *RecordTy);
222 void CollectCXXMemberFunctions(
const CXXRecordDecl *Decl, llvm::DIFile *F,
223 SmallVectorImpl<llvm::Metadata *> &E,
229 void CollectCXXBases(
const CXXRecordDecl *Decl, llvm::DIFile *F,
230 SmallVectorImpl<llvm::Metadata *> &EltTys,
231 llvm::DIType *RecordTy);
235 void CollectCXXBasesAux(
236 const CXXRecordDecl *RD, llvm::DIFile *Unit,
237 SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType *RecordTy,
238 const CXXRecordDecl::base_class_const_range &Bases,
240 llvm::DINode::DIFlags StartingFlags);
243 llvm::DINodeArray CollectTemplateParams(
const TemplateParameterList *TPList,
244 ArrayRef<TemplateArgument> TAList,
248 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
254 CollectCXXTemplateParams(
const ClassTemplateSpecializationDecl *TS,
257 llvm::DIType *createFieldType(StringRef name, QualType
type,
259 uint64_t offsetInBits, uint32_t AlignInBits,
260 llvm::DIFile *tunit, llvm::DIScope *scope,
261 const RecordDecl *RD =
nullptr);
263 llvm::DIType *createFieldType(StringRef name, QualType type,
265 uint64_t offsetInBits, llvm::DIFile *tunit,
266 llvm::DIScope *scope,
267 const RecordDecl *RD =
nullptr) {
268 return createFieldType(name, type, loc, AS, offsetInBits, 0, tunit, scope,
273 llvm::DIType *createBitFieldType(
const FieldDecl *BitFieldDecl,
274 llvm::DIScope *RecordTy,
275 const RecordDecl *RD);
279 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
280 SmallVectorImpl<llvm::Metadata *> &E,
281 llvm::DIType *RecordTy);
282 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
283 llvm::DIType *RecordTy,
284 const RecordDecl *RD);
285 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
287 SmallVectorImpl<llvm::Metadata *> &E,
288 llvm::DIType *RecordTy,
const RecordDecl *RD);
289 void CollectRecordNestedType(
const TypeDecl *RD,
290 SmallVectorImpl<llvm::Metadata *> &E);
291 void CollectRecordFields(
const RecordDecl *Decl, llvm::DIFile *F,
292 SmallVectorImpl<llvm::Metadata *> &E,
293 llvm::DICompositeType *RecordTy);
297 void CollectVTableInfo(
const CXXRecordDecl *Decl, llvm::DIFile *F,
298 SmallVectorImpl<llvm::Metadata *> &EltTys,
299 llvm::DICompositeType *RecordTy);
303 void CreateLexicalBlock(SourceLocation Loc);
311 void AppendAddressSpaceXDeref(
unsigned AddressSpace,
312 SmallVectorImpl<int64_t> &Expr)
const;
315 CGDebugInfo(CodeGenModule &CGM);
322 SizeExprCache[Ty] = SizeExpr;
328 void setDwoId(uint64_t Signature);
353 void setInlinedAt(llvm::MDNode *InlinedAt) { CurInlinedAt = InlinedAt; }
372 llvm::Function *Fn,
bool CurFnIsThunk,
384 void EmitFunctionEnd(
CGBuilderTy &Builder, llvm::Function *Fn);
398 llvm::DILocalVariable *EmitDeclareOfAutoVariable(
const VarDecl *Decl,
404 void EmitDeclareOfBlockDeclRefVariable(
406 const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint =
nullptr);
415 void EmitDeclareOfBlockLiteralArgVariable(
const CGBlockInfo &block,
416 StringRef Name,
unsigned ArgNo,
417 llvm::AllocaInst *LocalAddr,
421 void EmitGlobalVariable(llvm::GlobalVariable *GV,
const VarDecl *Decl);
430 void EmitExplicitCastType(
QualType Ty);
450 void completeType(
const EnumDecl *ED);
452 void completeRequiredType(
const RecordDecl *RD);
461 llvm::DIMacro *CreateMacro(llvm::DIMacroFile *
Parent,
unsigned MType,
466 llvm::DIMacroFile *CreateTempMacroFile(llvm::DIMacroFile *Parent,
479 llvm::DIType *EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
483 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
485 llvm::DIScope *getContextDescriptor(
const Decl *Context,
488 llvm::DIScope *getCurrentContextDescriptor(
const Decl *Decl);
491 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
495 StringRef getCurrentDirname();
498 void CreateCompileUnit();
501 std::string remapDIPath(StringRef)
const;
514 llvm::DIFile *getOrCreateMainFile();
517 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
523 bool CreateSkeletonCU);
526 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
530 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty,
534 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
537 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
538 StringRef Name, uint64_t *
Offset);
542 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
546 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
552 llvm::DIDerivedType *
553 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
556 llvm::DISubprogram *getFunctionFwdDeclOrStub(
GlobalDecl GD,
bool Stub);
560 llvm::DISubprogram *getFunctionForwardDeclaration(
GlobalDecl GD);
564 llvm::DISubprogram *getFunctionStub(
GlobalDecl GD);
568 llvm::DIGlobalVariable *
569 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
578 llvm::DIGlobalVariableExpression *
579 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
580 unsigned LineNo, StringRef LinkageName,
581 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
597 StringRef getSelectorName(
Selector S);
616 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
617 StringRef &Name, StringRef &LinkageName,
618 llvm::DIScope *&FDContext,
619 llvm::DINodeArray &TParamsArray,
620 llvm::DINode::DIFlags &Flags);
623 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
624 unsigned &LineNo,
QualType &T, StringRef &Name,
625 StringRef &LinkageName, llvm::DIScope *&VDContext);
630 StringRef internString(StringRef A, StringRef B = StringRef()) {
631 char *Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
636 return StringRef(Data, A.size() + B.size());
644 void init(
SourceLocation TemporaryLocation,
bool DefaultToEmpty =
false);
648 llvm::DebugLoc OriginalLocation;
712 #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 ...
Expr - 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.
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.
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.