14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
15 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/Optional.h"
24 #include "llvm/IR/DIBuilder.h"
25 #include "llvm/IR/DebugInfo.h"
26 #include "llvm/IR/ValueHandle.h"
27 #include "llvm/Support/Allocator.h"
35 class ClassTemplateSpecializationDecl;
38 class ObjCInterfaceDecl;
45 class CodeGenFunction;
56 bool DebugTypeExtRefs;
57 llvm::DIBuilder DBuilder;
58 llvm::DICompileUnit *TheCU =
nullptr;
61 llvm::DIType *VTablePtrType =
nullptr;
62 llvm::DIType *ClassTy =
nullptr;
63 llvm::DICompositeType *ObjTy =
nullptr;
64 llvm::DIType *SelTy =
nullptr;
65 llvm::DIType *OCLImage1dDITy =
nullptr;
66 llvm::DIType *OCLImage1dArrayDITy =
nullptr;
67 llvm::DIType *OCLImage1dBufferDITy =
nullptr;
68 llvm::DIType *OCLImage2dDITy =
nullptr;
69 llvm::DIType *OCLImage2dArrayDITy =
nullptr;
70 llvm::DIType *OCLImage2dDepthDITy =
nullptr;
71 llvm::DIType *OCLImage2dArrayDepthDITy =
nullptr;
72 llvm::DIType *OCLImage2dMSAADITy =
nullptr;
73 llvm::DIType *OCLImage2dArrayMSAADITy =
nullptr;
74 llvm::DIType *OCLImage2dMSAADepthDITy =
nullptr;
75 llvm::DIType *OCLImage2dArrayMSAADepthDITy =
nullptr;
76 llvm::DIType *OCLImage3dDITy =
nullptr;
77 llvm::DIType *OCLEventDITy =
nullptr;
78 llvm::DIType *OCLClkEventDITy =
nullptr;
79 llvm::DIType *OCLQueueDITy =
nullptr;
80 llvm::DIType *OCLNDRangeDITy =
nullptr;
81 llvm::DIType *OCLReserveIDDITy =
nullptr;
84 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
86 llvm::SmallDenseMap<llvm::StringRef, llvm::StringRef> DebugPrefixMap;
88 struct ObjCInterfaceCacheEntry {
94 : Type(Type), Decl(Decl), Unit(Unit) {}
101 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
104 std::vector<void *> RetainedTypes;
108 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
112 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
116 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
117 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
121 std::vector<unsigned> FnBeginRegionCount;
125 llvm::BumpPtrAllocator DebugInfoNames;
128 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
129 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
132 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
133 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NameSpaceCache;
134 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
136 llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIDerivedType>>
137 StaticDataMemberCache;
145 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
146 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
150 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
152 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
154 llvm::DIType *CreateType(
const RecordType *Tyg);
155 llvm::DIType *CreateTypeDefinition(
const RecordType *Ty);
156 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
158 llvm::DICompositeType *CT);
164 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
165 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
166 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
170 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
171 llvm::DIType *CreateType(
const PipeType *Ty, llvm::DIFile *F);
173 llvm::DIType *CreateEnumType(
const EnumType *Ty);
174 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
181 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
186 llvm::DIType *getTypeOrNull(
const QualType);
191 llvm::DISubroutineType *getOrCreateMethodType(
const CXXMethodDecl *Method,
193 llvm::DISubroutineType *
196 llvm::DISubroutineType *
197 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
199 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
201 llvm::DINamespace *getOrCreateNameSpace(
const NamespaceDecl *N);
202 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
203 QualType PointeeTy, llvm::DIFile *F);
204 llvm::DIType *getOrCreateStructPtrType(StringRef
Name, llvm::DIType *&
Cache);
208 llvm::DISubprogram *CreateCXXMemberFunction(
const CXXMethodDecl *Method,
210 llvm::DIType *RecordTy);
224 llvm::DIType *RecordTy);
232 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
241 llvm::DIType *createFieldType(StringRef name,
QualType type,
244 llvm::DIFile *tunit, llvm::DIScope *scope,
251 llvm::DIType *RecordTy);
252 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
253 llvm::DIType *RecordTy,
255 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
258 llvm::DIType *RecordTy,
const RecordDecl *RD);
261 llvm::DICompositeType *RecordTy);
328 llvm::Instruction *InsertPoint =
nullptr);
385 llvm::DIType *EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
389 llvm::DIScope *getDeclContextDescriptor(
const Decl *D);
391 llvm::DIScope *getContextDescriptor(
const Decl *
Context,
392 llvm::DIScope *Default);
394 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
397 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
401 StringRef getCurrentDirname();
404 void CreateCompileUnit();
407 std::string remapDIPath(StringRef)
const;
413 llvm::DIFile *getOrCreateMainFile();
416 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
422 bool CreateSkeletonCU);
425 llvm::DIModule *getParentModuleOrNull(
const Decl *D);
429 llvm::DICompositeType *getOrCreateLimitedType(
const RecordType *Ty,
433 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
436 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
441 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
445 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
451 llvm::DIDerivedType *
452 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
456 llvm::DISubprogram *getFunctionForwardDeclaration(
const FunctionDecl *FD);
460 llvm::DIGlobalVariable *
461 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
470 llvm::DIGlobalVariable *
471 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
472 unsigned LineNo, StringRef LinkageName,
473 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
505 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
506 StringRef &
Name, StringRef &LinkageName,
507 llvm::DIScope *&FDContext,
508 llvm::DINodeArray &TParamsArray,
512 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
514 StringRef &LinkageName, llvm::DIScope *&VDContext);
519 StringRef internString(StringRef A, StringRef B = StringRef()) {
520 char *Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
522 std::memcpy(Data, A.data(), A.size());
524 std::memcpy(Data + A.size(), B.data(), B.size());
525 return StringRef(Data, A.size() + B.size());
533 void init(
SourceLocation TemporaryLocation,
bool DefaultToEmpty =
false);
537 llvm::DebugLoc OriginalLocation;
588 #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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
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.
FunctionType - C99 6.7.5.3 - Function Declarators.
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.
Decl - This represents one declaration (or definition), e.g.
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
The base class of the type hierarchy.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
NamespaceDecl - Represent a C++ namespace.
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 ...
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.
Stores a list of template parameters for a TemplateDecl and its derived classes.
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. ...
Represents a class type in Objective C.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void EmitImportDecl(const ImportDecl &ID)
Emit an declaration.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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
An rvalue reference type, per C++11 [dcl.ref].
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.
Represents a prototype with parameter type info, e.g.
CGBlockInfo - Information to generate a block literal.
void setDwoId(uint64_t Signature)
Set the main CU's DwoId field to Signature.
ID
Defines the set of possible language-specific address spaces.
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.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Interfaces are the core concept in Objective-C for object oriented design.
void completeRequiredType(const RecordDecl *RD)
A scoped helper to set the current debug location to the specified location or preferred location of ...
Represents a static or instance method of a struct/union/class.
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
A pointer to member type per C++ 8.3.3 - Pointers to members.
void setModuleMap(ModuleMap &MMap)
When generating debug information for a clang module or precompiled header, this module map will be u...
Represents a pointer to an Objective C object.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
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.
This class is used for builtin types like 'int'.
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.