14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
15 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
23 #include "llvm/ADT/DenseMap.h"
24 #include "llvm/ADT/Optional.h"
25 #include "llvm/IR/DIBuilder.h"
26 #include "llvm/IR/DebugInfo.h"
27 #include "llvm/IR/ValueHandle.h"
28 #include "llvm/Support/Allocator.h"
36 class ClassTemplateSpecializationDecl;
39 class ObjCInterfaceDecl;
46 class CodeGenFunction;
57 bool DebugTypeExtRefs;
58 llvm::DIBuilder DBuilder;
59 llvm::DICompileUnit *TheCU =
nullptr;
63 llvm::DIType *VTablePtrType =
nullptr;
64 llvm::DIType *ClassTy =
nullptr;
65 llvm::DICompositeType *ObjTy =
nullptr;
66 llvm::DIType *SelTy =
nullptr;
67 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
68 llvm::DIType *SingletonId = nullptr;
69 #include "clang/Basic/OpenCLImageTypes.def"
70 llvm::DIType *OCLEventDITy =
nullptr;
71 llvm::DIType *OCLClkEventDITy =
nullptr;
72 llvm::DIType *OCLQueueDITy =
nullptr;
73 llvm::DIType *OCLNDRangeDITy =
nullptr;
74 llvm::DIType *OCLReserveIDDITy =
nullptr;
77 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
79 llvm::SmallDenseMap<llvm::StringRef, llvm::StringRef> DebugPrefixMap;
81 struct ObjCInterfaceCacheEntry {
82 const ObjCInterfaceType *
Type;
85 ObjCInterfaceCacheEntry(
const ObjCInterfaceType *
Type, llvm::DIType *
Decl,
87 :
Type(Type),
Decl(Decl), Unit(Unit) {}
94 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
97 std::vector<void *> RetainedTypes;
101 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
105 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
109 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
110 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
114 std::vector<unsigned> FnBeginRegionCount;
118 llvm::BumpPtrAllocator DebugInfoNames;
121 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
122 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
125 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
126 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NameSpaceCache;
127 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
129 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
130 StaticDataMemberCache;
136 llvm::DIType *CreateType(
const BuiltinType *Ty);
137 llvm::DIType *CreateType(
const ComplexType *Ty);
138 llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
139 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
142 llvm::DIType *CreateType(
const ObjCObjectPointerType *Ty, llvm::DIFile *F);
143 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
144 llvm::DIType *CreateType(
const BlockPointerType *Ty, llvm::DIFile *F);
145 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
147 llvm::DIType *CreateType(
const RecordType *Tyg);
148 llvm::DIType *CreateTypeDefinition(
const RecordType *Ty);
149 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
150 void CollectContainingType(
const CXXRecordDecl *RD,
151 llvm::DICompositeType *CT);
153 llvm::DIType *CreateType(
const ObjCInterfaceType *Ty, llvm::DIFile *F);
154 llvm::DIType *CreateTypeDefinition(
const ObjCInterfaceType *Ty,
157 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
158 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
159 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
160 llvm::DIType *CreateType(
const LValueReferenceType *Ty, llvm::DIFile *F);
161 llvm::DIType *CreateType(
const RValueReferenceType *Ty, llvm::DIFile *Unit);
162 llvm::DIType *CreateType(
const MemberPointerType *Ty, llvm::DIFile *F);
163 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
164 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
166 llvm::DIType *CreateEnumType(
const EnumType *Ty);
167 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
174 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
179 llvm::DIType *getTypeOrNull(
const QualType);
184 llvm::DISubroutineType *getOrCreateMethodType(
const CXXMethodDecl *Method,
186 llvm::DISubroutineType *
187 getOrCreateInstanceMethodType(QualType ThisPtr,
const FunctionProtoType *Func,
189 llvm::DISubroutineType *
190 getOrCreateFunctionType(
const Decl *D, QualType FnType, llvm::DIFile *F);
192 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
194 llvm::DINamespace *getOrCreateNameSpace(
const NamespaceDecl *N);
195 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
196 QualType PointeeTy, llvm::DIFile *F);
197 llvm::DIType *getOrCreateStructPtrType(StringRef
Name, llvm::DIType *&
Cache);
201 llvm::DISubprogram *CreateCXXMemberFunction(
const CXXMethodDecl *Method,
203 llvm::DIType *RecordTy);
208 void CollectCXXMemberFunctions(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
209 SmallVectorImpl<llvm::Metadata *> &
E,
215 void CollectCXXBases(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
216 SmallVectorImpl<llvm::Metadata *> &EltTys,
217 llvm::DIType *RecordTy);
220 llvm::DINodeArray CollectTemplateParams(
const TemplateParameterList *TPList,
221 ArrayRef<TemplateArgument> TAList,
225 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
231 CollectCXXTemplateParams(
const ClassTemplateSpecializationDecl *TS,
234 llvm::DIType *createFieldType(StringRef name, QualType
type,
236 uint64_t offsetInBits, llvm::DIFile *tunit,
237 llvm::DIScope *scope,
238 const RecordDecl *RD =
nullptr);
241 llvm::DIType *createBitFieldType(
const FieldDecl *BitFieldDecl,
242 llvm::DIScope *RecordTy,
243 const RecordDecl *RD);
247 void CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl,
248 SmallVectorImpl<llvm::Metadata *> &
E,
249 llvm::DIType *RecordTy);
250 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
251 llvm::DIType *RecordTy,
252 const RecordDecl *RD);
253 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
255 SmallVectorImpl<llvm::Metadata *> &
E,
256 llvm::DIType *RecordTy,
const RecordDecl *RD);
257 void CollectRecordFields(
const RecordDecl *
Decl, llvm::DIFile *F,
258 SmallVectorImpl<llvm::Metadata *> &
E,
259 llvm::DICompositeType *RecordTy);
263 void CollectVTableInfo(
const CXXRecordDecl *
Decl, llvm::DIFile *F,
264 SmallVectorImpl<llvm::Metadata *> &EltTys);
268 void CreateLexicalBlock(SourceLocation Loc);
336 llvm::Instruction *InsertPoint =
nullptr);
393 llvm::DIType *EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
397 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
399 llvm::DIScope *getContextDescriptor(
const Decl *
Context,
400 llvm::DIScope *Default);
402 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
405 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
409 StringRef getCurrentDirname();
412 void CreateCompileUnit();
415 std::string remapDIPath(StringRef)
const;
421 llvm::DIFile *getOrCreateMainFile();
424 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
430 bool CreateSkeletonCU);
433 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
437 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty,
441 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
444 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
449 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
453 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
459 llvm::DIDerivedType *
460 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
464 llvm::DISubprogram *getFunctionForwardDeclaration(
const FunctionDecl *FD);
468 llvm::DIGlobalVariable *
469 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
478 llvm::DIGlobalVariable *
479 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
480 unsigned LineNo, StringRef LinkageName,
481 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
513 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
514 StringRef &
Name, StringRef &LinkageName,
515 llvm::DIScope *&FDContext,
516 llvm::DINodeArray &TParamsArray,
520 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
522 StringRef &LinkageName, llvm::DIScope *&VDContext);
527 StringRef internString(StringRef A, StringRef B = StringRef()) {
528 char *Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
530 std::memcpy(Data, A.data(), A.size());
532 std::memcpy(Data + A.size(), B.data(), B.size());
533 return StringRef(Data, A.size() + B.size());
541 void init(
SourceLocation TemporaryLocation,
bool DefaultToEmpty =
false);
545 llvm::DebugLoc OriginalLocation;
596 #endif // LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, llvm::Value *Arg, unsigned ArgNo, llvm::Value *LocalAddr, CGBuilderTy &Builder)
Emit call to llvm.dbg.declare for the block-literal argument to a block invocation function...
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
void EmitExplicitCastType(QualType Ty)
Emit the type explicitly casted to.
llvm::DIType * getOrCreateRecordType(QualType Ty, SourceLocation L)
Emit record type's standalone debug info.
void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the end of a new lexical block and pop the current block.
C Language Family Type Representation.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void setPCHDescriptor(ExternalASTSource::ASTSourceDescriptor PCH)
When generating debug information for a clang module or precompiled header, this module map will be u...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI, CGBuilderTy &Builder)
Emit call to llvm.dbg.declare for an automatic variable declaration.
ObjCMethodDecl - Represents an instance or class method declaration.
void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD)
RecordDecl - Represents a struct/union/class.
Represents a class template specialization, which refers to a class template with a given set of temp...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void EmitImportDecl(const ImportDecl &ID)
Emit an declaration.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void completeClassData(const RecordDecl *RD)
static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF)
Apply TemporaryLocation if it is valid.
Represents a C++ using-declaration.
friend class SaveAndRestoreLocation
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about a global variable.
llvm::DIType * getOrCreateInterfaceType(QualType Ty, SourceLocation Loc)
Emit an Objective-C interface type standalone debug info.
llvm::DIImportedEntity * EmitNamespaceAlias(const NamespaceAliasDecl &NA)
Emit C++ namespace alias.
CGBlockInfo - Information to generate a block literal.
void setDwoId(uint64_t Signature)
Module debugging: Support for building PCMs.
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate a change in line/column information in the source file. ...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
GlobalDecl - represents a global declaration.
The l-value was considered opaque, so the alignment was determined from a type.
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned ArgNo, CGBuilderTy &Builder)
Emit call to llvm.dbg.declare for an argument variable declaration.
void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType)
Emit debug info for a function declaration.
Encodes a location in the source.
void completeRequiredType(const RecordDecl *RD)
A scoped helper to set the current debug location to the specified location or preferred location of ...
Describes a module import declaration, which makes the contents of the named module visible in the cu...
This class organizes the cross-function state that is used while generating LLVM code.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
CGDebugInfo(CodeGenModule &CGM)
EnumDecl - Represents an enum.
detail::InMemoryDirectory::const_iterator E
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...
llvm::DIType * getOrCreateStandaloneType(QualType Ty, SourceLocation Loc)
Emit standalone debug info for a type.
void completeType(const EnumDecl *ED)
ApplyDebugLocation(ApplyDebugLocation &&Other)
void EmitUsingDecl(const UsingDecl &UD)
Emit C++ using declaration.
void EmitUsingDirective(const UsingDirectiveDecl &UD)
Emit C++ using directive.
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the beginning of a new lexical block and push the block onto the stack...
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder, const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint=nullptr)
Emit call to llvm.dbg.declare for an imported variable declaration in a block.
void EmitFunctionStart(GlobalDecl GD, SourceLocation Loc, SourceLocation ScopeLoc, QualType FnType, llvm::Function *Fn, CGBuilderTy &Builder)
Emit a call to llvm.dbg.function.start to indicate start of a new function.
void setLocation(SourceLocation Loc)
Update the current source location.
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.
void EmitFunctionEnd(CGBuilderTy &Builder)
Constructs the debug code for exiting a function.
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)