Lines Matching +full:llvm +full:-

1 //===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
8 //===----------------------------------------------------------------------===//
10 // This is the source-level debug info generator for llvm translation.
12 //===----------------------------------------------------------------------===//
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"
30 namespace llvm {
50 /// responsible for emitting to llvm globals or pass directly to the
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;
68 llvm::DIType *SingletonId = nullptr;
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;
83 llvm::DIType *Decl;
84 llvm::DIFile *Unit;
85 ObjCInterfaceCacheEntry(const ObjCInterfaceType *Type, llvm::DIType *Decl, in ObjCInterfaceCacheEntry()
86 llvm::DIFile *Unit) in ObjCInterfaceCacheEntry()
91 llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
94 llvm::DenseMap<const Module *, llvm::TrackingMDRef> ModuleCache;
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;
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>>
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);
140 llvm::DIType *CreateType(const TemplateSpecializationType *Ty,
141 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);
151 llvm::DICompositeType *CT);
152 /// Get Objective-C interface type.
153 llvm::DIType *CreateType(const ObjCInterfaceType *Ty, llvm::DIFile *F);
154 llvm::DIType *CreateTypeDefinition(const ObjCInterfaceType *Ty,
155 llvm::DIFile *F);
156 /// Get Objective-C object type.
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,
185 llvm::DIFile *F);
186 llvm::DISubroutineType *
188 llvm::DIFile *Unit);
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,
202 llvm::DIFile *F,
203 llvm::DIType *RecordTy);
208 void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, llvm::DIFile *F,
209 SmallVectorImpl<llvm::Metadata *> &E,
210 llvm::DIType *T);
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,
222 llvm::DIFile *Unit);
225 llvm::DINodeArray CollectFunctionTemplateParams(const FunctionDecl *FD,
226 llvm::DIFile *Unit);
230 llvm::DINodeArray
232 llvm::DIFile *F);
234 llvm::DIType *createFieldType(StringRef name, QualType type,
236 uint64_t offsetInBits, llvm::DIFile *tunit,
237 llvm::DIScope *scope,
241 llvm::DIType *createBitFieldType(const FieldDecl *BitFieldDecl,
242 llvm::DIScope *RecordTy,
248 SmallVectorImpl<llvm::Metadata *> &E,
249 llvm::DIType *RecordTy);
250 llvm::DIDerivedType *CreateRecordStaticField(const VarDecl *Var,
251 llvm::DIType *RecordTy,
254 llvm::DIFile *F,
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);
303 /// Emit a call to llvm.dbg.function.start to indicate
309 llvm::Function *Fn, CGBuilderTy &Builder);
325 /// Emit call to \c llvm.dbg.declare for an automatic variable
327 void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
330 /// Emit call to \c llvm.dbg.declare for an imported variable
333 llvm::Value *storage,
336 llvm::Instruction *InsertPoint = nullptr);
338 /// Emit call to \c llvm.dbg.declare for an argument variable
340 void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
343 /// Emit call to \c llvm.dbg.declare for the block-literal argument
346 llvm::Value *Arg, unsigned ArgNo,
347 llvm::Value *LocalAddr,
351 void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
354 void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init);
369 llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl &NA);
372 llvm::DIType *getOrCreateRecordType(QualType Ty, SourceLocation L);
374 /// Emit an Objective-C interface type standalone debug info.
375 llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
378 llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
388 /// Emit call to llvm.dbg.declare for a variable declaration.
389 void EmitDeclare(const VarDecl *decl, llvm::Value *AI,
390 llvm::Optional<unsigned> ArgNo, CGBuilderTy &Builder);
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 *,
406 llvm::DIScope *);
418 llvm::DIFile *getOrCreateFile(SourceLocation Loc);
421 llvm::DIFile *getOrCreateMainFile();
424 llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg);
428 llvm::DIModule *
433 llvm::DIModule *getParentModuleOrNull(const Decl *D);
437 llvm::DICompositeType *getOrCreateLimitedType(const RecordType *Ty,
438 llvm::DIFile *F);
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);
455 /// \return debug info descriptor to describe in-class static data
456 /// member declaration for the given out-of-class definition. If D
457 /// is an out-of-class definition of a static data member of a
458 /// class, find its corresponding in-class declaration.
459 llvm::DIDerivedType *
464 llvm::DISubprogram *getFunctionForwardDeclaration(const FunctionDecl *FD);
468 llvm::DIGlobalVariable *
478 llvm::DIGlobalVariable *
479 CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile *Unit,
481 llvm::GlobalVariable *Var, llvm::DIScope *DContext);
488 /// Returns the unmangled name of an Objective-C method.
513 void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
515 llvm::DIScope *&FDContext,
516 llvm::DINodeArray &TParamsArray,
520 void collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
522 StringRef &LinkageName, llvm::DIScope *&VDContext);
545 llvm::DebugLoc OriginalLocation;
552 ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc);
563 /// Artificial locations are useful when emitting compiler-generated