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/IR/DIBuilder.h"
24 #include "llvm/IR/DebugInfo.h"
25 #include "llvm/IR/ValueHandle.h"
26 #include "llvm/Support/Allocator.h"
35 class ObjCInterfaceDecl;
37 class ClassTemplateSpecializationDecl;
43 class CodeGenFunction;
54 llvm::DIBuilder DBuilder;
55 llvm::DICompileUnit *TheCU =
nullptr;
57 llvm::DIType *VTablePtrType =
nullptr;
58 llvm::DIType *ClassTy =
nullptr;
59 llvm::DICompositeType *ObjTy =
nullptr;
60 llvm::DIType *SelTy =
nullptr;
61 llvm::DIType *OCLImage1dDITy =
nullptr;
62 llvm::DIType *OCLImage1dArrayDITy =
nullptr;
63 llvm::DIType *OCLImage1dBufferDITy =
nullptr;
64 llvm::DIType *OCLImage2dDITy =
nullptr;
65 llvm::DIType *OCLImage2dArrayDITy =
nullptr;
66 llvm::DIType *OCLImage3dDITy =
nullptr;
67 llvm::DIType *OCLEventDITy =
nullptr;
70 llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
72 struct ObjCInterfaceCacheEntry {
78 : Type(Type), Decl(Decl), Unit(Unit) {}
85 llvm::DenseMap<uint64_t, llvm::DIModule *> ModuleRefCache;
88 std::vector<void *> RetainedTypes;
92 std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;
96 std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>>
100 std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
101 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
105 std::vector<unsigned> FnBeginRegionCount;
109 llvm::BumpPtrAllocator DebugInfoNames;
112 llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
113 llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
116 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;
117 llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NameSpaceCache;
118 llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef>
120 llvm::DenseMap<const Decl *, llvm::TrackingMDRef> StaticDataMemberCache;
129 llvm::DIType *CreateQualifiedType(
QualType Ty, llvm::DIFile *Fg);
130 llvm::DIType *CreateType(
const TypedefType *Ty, llvm::DIFile *Fg);
134 llvm::DIType *CreateType(
const PointerType *Ty, llvm::DIFile *F);
136 llvm::DIType *CreateType(
const FunctionType *Ty, llvm::DIFile *F);
138 llvm::DIType *CreateType(
const RecordType *Tyg);
139 llvm::DIType *CreateTypeDefinition(
const RecordType *Ty);
140 llvm::DICompositeType *CreateLimitedType(
const RecordType *Ty);
142 llvm::DICompositeType *CT);
148 llvm::DIType *CreateType(
const ObjCObjectType *Ty, llvm::DIFile *F);
149 llvm::DIType *CreateType(
const VectorType *Ty, llvm::DIFile *F);
150 llvm::DIType *CreateType(
const ArrayType *Ty, llvm::DIFile *F);
154 llvm::DIType *CreateType(
const AtomicType *Ty, llvm::DIFile *F);
156 llvm::DIType *CreateEnumType(
const EnumType *Ty);
157 llvm::DIType *CreateTypeDefinition(
const EnumType *Ty);
164 llvm::DIType *CreateSelfType(
const QualType &QualTy, llvm::DIType *Ty);
169 llvm::DIType *getTypeOrNull(
const QualType);
174 llvm::DISubroutineType *getOrCreateMethodType(
const CXXMethodDecl *Method,
176 llvm::DISubroutineType *
179 llvm::DISubroutineType *
180 getOrCreateFunctionType(
const Decl *D,
QualType FnType, llvm::DIFile *F);
182 llvm::DIType *getOrCreateVTablePtrType(llvm::DIFile *F);
184 llvm::DINamespace *getOrCreateNameSpace(
const NamespaceDecl *N);
185 llvm::DIType *getOrCreateTypeDeclaration(
QualType PointeeTy, llvm::DIFile *F);
186 llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty,
187 QualType PointeeTy, llvm::DIFile *F);
190 llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&
Cache);
194 llvm::DISubprogram *CreateCXXMemberFunction(
const CXXMethodDecl *Method,
196 llvm::DIType *RecordTy);
210 llvm::DIType *RecordTy);
218 llvm::DINodeArray CollectFunctionTemplateParams(
const FunctionDecl *FD,
227 llvm::DIType *createFieldType(StringRef name,
QualType type,
230 llvm::DIFile *tunit, llvm::DIScope *scope,
237 llvm::DIType *RecordTy);
238 llvm::DIDerivedType *CreateRecordStaticField(
const VarDecl *Var,
239 llvm::DIType *RecordTy,
241 void CollectRecordNormalField(
const FieldDecl *Field, uint64_t OffsetInBits,
244 llvm::DIType *RecordTy,
const RecordDecl *RD);
247 llvm::DICompositeType *RecordTy);
302 const CGBlockInfo &blockInfo,
303 llvm::Instruction *InsertPoint = 0);
359 llvm::DIType *EmitTypeForVarWithBlocksAttr(
const VarDecl *VD,
363 llvm::DIScope *getContextDescriptor(
const Decl *
Decl);
365 llvm::DIScope *getCurrentContextDescriptor(
const Decl *
Decl);
368 llvm::DICompositeType *getOrCreateRecordFwdDecl(
const RecordType *,
372 StringRef getCurrentDirname();
375 void CreateCompileUnit();
381 llvm::DIFile *getOrCreateMainFile();
384 llvm::DIType *getOrCreateType(
QualType Ty, llvm::DIFile *Fg);
392 llvm::DIType *getOrCreateLimitedType(
const RecordType *Ty, llvm::DIFile *F);
395 llvm::DIType *CreateTypeNode(
QualType Ty, llvm::DIFile *Fg);
402 llvm::DIType *CreateMemberType(llvm::DIFile *Unit,
QualType FType,
403 StringRef Name, uint64_t *
Offset);
407 llvm::DINode *getDeclarationOrDefinition(
const Decl *D);
411 llvm::DISubprogram *getFunctionDeclaration(
const Decl *D);
417 llvm::DIDerivedType *
418 getOrCreateStaticDataMemberDeclarationOrNull(
const VarDecl *D);
422 llvm::DISubprogram *getFunctionForwardDeclaration(
const FunctionDecl *FD);
426 llvm::DIGlobalVariable *
427 getGlobalVariableForwardDeclaration(
const VarDecl *VD);
436 llvm::DIGlobalVariable *
437 CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile *Unit,
438 unsigned LineNo, StringRef LinkageName,
439 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
471 void collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile *Unit,
472 StringRef &Name, StringRef &LinkageName,
473 llvm::DIScope *&FDContext,
474 llvm::DINodeArray &TParamsArray,
478 void collectVarDeclProps(
const VarDecl *VD, llvm::DIFile *&Unit,
479 unsigned &LineNo,
QualType &T, StringRef &Name,
480 StringRef &LinkageName, llvm::DIScope *&VDContext);
485 StringRef internString(StringRef A, StringRef B = StringRef()) {
486 char *Data = DebugInfoNames.Allocate<
char>(A.size() + B.size());
488 std::memcpy(Data, A.data(), A.size());
490 std::memcpy(Data + A.size(), B.data(), B.size());
491 return StringRef(Data, A.size() + B.size());
499 void init(
SourceLocation TemporaryLocation,
bool DefaultToEmpty =
false);
503 llvm::DebugLoc OriginalLocation;
void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, llvm::Value *Arg, unsigned ArgNo, llvm::Value *LocalAddr, CGBuilderTy &Builder)
Smart pointer class that efficiently represents Objective-C method names.
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)
NamespaceDecl - Represent a C++ namespace.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI, CGBuilderTy &Builder)
Stores a list of template parameters for a TemplateDecl and its derived classes.
void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD)
Represents a class template specialization, which refers to a class template with a given set of temp...
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. Otherwise switch to an artificial debug location that has a v...
void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder, const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint=0)
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.
Represents an ObjC class declaration.
ID
Defines the set of possible language-specific address spaces.
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc)
llvm::IRBuilder< PreserveNames, llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderTy
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned ArgNo, CGBuilderTy &Builder)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
void completeRequiredType(const RecordDecl *RD)
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...
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid. Otherwise switch to an artificial debug location that has a v...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
CGDebugInfo(CodeGenModule &CGM)
static ApplyDebugLocation CreateDefaultEmpty(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid. Otherwise set the IRBuilder to not attach debug locations...
void completeType(const EnumDecl *ED)
void EmitUsingDecl(const UsingDecl &UD)
Emit C++ using declaration.
void EmitUsingDirective(const UsingDirectiveDecl &UD)
Emit C++ using directive.
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc)
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
void EmitFunctionStart(GlobalDecl GD, SourceLocation Loc, SourceLocation ScopeLoc, QualType FnType, llvm::Function *Fn, CGBuilderTy &Builder)
void setLocation(SourceLocation Loc)
Represents a type template specialization; the template must be a class template, a type alias templa...
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Represents a C++ namespace alias.
Represents C++ using-directive.
void EmitFunctionEnd(CGBuilderTy &Builder)
Constructs the debug code for exiting a function.
Holds everything needed to generate debug info for an imported module or precompiled header file...