LLVM  3.7.0
DIBuilder.h
Go to the documentation of this file.
1 //===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines a DIBuilder that is useful for creating debugging
11 // information entries in LLVM IR form.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_DIBUILDER_H
16 #define LLVM_IR_DIBUILDER_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/IR/DebugInfo.h"
21 #include "llvm/IR/TrackingMDRef.h"
22 #include "llvm/IR/ValueHandle.h"
23 #include "llvm/Support/DataTypes.h"
24 
25 namespace llvm {
26  class BasicBlock;
27  class Instruction;
28  class Function;
29  class Module;
30  class Value;
31  class Constant;
32  class LLVMContext;
33  class StringRef;
34 
35  class DIBuilder {
36  Module &M;
37  LLVMContext &VMContext;
38 
39  DICompileUnit *CUNode; ///< The one compile unit created by this DIBuiler.
40  Function *DeclareFn; ///< llvm.dbg.declare
41  Function *ValueFn; ///< llvm.dbg.value
42 
43  SmallVector<Metadata *, 4> AllEnumTypes;
44  /// Track the RetainTypes, since they can be updated later on.
45  SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
46  SmallVector<Metadata *, 4> AllSubprograms;
48  SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
49 
50  /// Track nodes that may be unresolved.
51  SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
52  bool AllowUnresolvedNodes;
53 
54  /// Each subprogram's preserved local variables.
56 
57  DIBuilder(const DIBuilder &) = delete;
58  void operator=(const DIBuilder &) = delete;
59 
60  /// Create a temporary.
61  ///
62  /// Create an \a temporary node and track it in \a UnresolvedNodes.
63  void trackIfUnresolved(MDNode *N);
64 
65  public:
66  /// Construct a builder for a module.
67  ///
68  /// If \c AllowUnresolved, collect unresolved nodes attached to the module
69  /// in order to resolve cycles during \a finalize().
70  explicit DIBuilder(Module &M, bool AllowUnresolved = true);
72 
73  /// Construct any deferred debug info descriptors.
74  void finalize();
75 
76  /// A CompileUnit provides an anchor for all debugging
77  /// information generated during this instance of compilation.
78  /// \param Lang Source programming language, eg. dwarf::DW_LANG_C99
79  /// \param File File name
80  /// \param Dir Directory
81  /// \param Producer Identify the producer of debugging information
82  /// and code. Usually this is a compiler
83  /// version string.
84  /// \param isOptimized A boolean flag which indicates whether optimization
85  /// is enabled or not.
86  /// \param Flags This string lists command line options. This
87  /// string is directly embedded in debug info
88  /// output which may be used by a tool
89  /// analyzing generated debugging information.
90  /// \param RV This indicates runtime version for languages like
91  /// Objective-C.
92  /// \param SplitName The name of the file that we'll split debug info
93  /// out into.
94  /// \param Kind The kind of debug information to generate.
95  /// \param DWOId The DWOId if this is a split skeleton compile unit.
96  /// \param EmitDebugInfo A boolean flag which indicates whether
97  /// debug information should be written to
98  /// the final output or not. When this is
99  /// false, debug information annotations will
100  /// be present in the IL but they are not
101  /// written to the final assembly or object
102  /// file. This supports tracking source
103  /// location information in the back end
104  /// without actually changing the output
105  /// (e.g., when using optimization remarks).
106  DICompileUnit *
107  createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
108  StringRef Producer, bool isOptimized, StringRef Flags,
109  unsigned RV, StringRef SplitName = StringRef(),
110  DebugEmissionKind Kind = FullDebug, uint64_t DWOId = 0,
111  bool EmitDebugInfo = true);
112 
113  /// Create a file descriptor to hold debugging information
114  /// for a file.
115  DIFile *createFile(StringRef Filename, StringRef Directory);
116 
117  /// Create a single enumerator value.
119 
120  /// Create a DWARF unspecified type.
122 
123  /// Create C++11 nullptr type.
125 
126  /// Create debugging information entry for a basic
127  /// type.
128  /// \param Name Type name.
129  /// \param SizeInBits Size of the type.
130  /// \param AlignInBits Type alignment.
131  /// \param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
132  DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
133  uint64_t AlignInBits, unsigned Encoding);
134 
135  /// Create debugging information entry for a qualified
136  /// type, e.g. 'const int'.
137  /// \param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
138  /// \param FromTy Base Type.
139  DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
140 
141  /// Create debugging information entry for a pointer.
142  /// \param PointeeTy Type pointed by this pointer.
143  /// \param SizeInBits Size.
144  /// \param AlignInBits Alignment. (optional)
145  /// \param Name Pointer type name. (optional)
146  DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
147  uint64_t AlignInBits = 0,
148  StringRef Name = "");
149 
150  /// Create debugging information entry for a pointer to member.
151  /// \param PointeeTy Type pointed to by this pointer.
152  /// \param SizeInBits Size.
153  /// \param AlignInBits Alignment. (optional)
154  /// \param Class Type for which this pointer points to members of.
156  uint64_t SizeInBits,
157  uint64_t AlignInBits = 0);
158 
159  /// Create debugging information entry for a c++
160  /// style reference or rvalue reference type.
161  DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy);
162 
163  /// Create debugging information entry for a typedef.
164  /// \param Ty Original type.
165  /// \param Name Typedef name.
166  /// \param File File where this type is defined.
167  /// \param LineNo Line number.
168  /// \param Context The surrounding context for the typedef.
170  unsigned LineNo, DIScope *Context);
171 
172  /// Create debugging information entry for a 'friend'.
173  DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
174 
175  /// Create debugging information entry to establish
176  /// inheritance relationship between two types.
177  /// \param Ty Original type.
178  /// \param BaseTy Base type. Ty is inherits from base.
179  /// \param BaseOffset Base offset.
180  /// \param Flags Flags to describe inheritance attribute,
181  /// e.g. private
183  uint64_t BaseOffset, unsigned Flags);
184 
185  /// Create debugging information entry for a member.
186  /// \param Scope Member scope.
187  /// \param Name Member name.
188  /// \param File File where this member is defined.
189  /// \param LineNo Line number.
190  /// \param SizeInBits Member size.
191  /// \param AlignInBits Member alignment.
192  /// \param OffsetInBits Member offset.
193  /// \param Flags Flags to encode member attribute, e.g. private
194  /// \param Ty Parent type.
196  DIFile *File, unsigned LineNo,
197  uint64_t SizeInBits, uint64_t AlignInBits,
198  uint64_t OffsetInBits, unsigned Flags,
199  DIType *Ty);
200 
201  /// Create debugging information entry for a
202  /// C++ static data member.
203  /// \param Scope Member scope.
204  /// \param Name Member name.
205  /// \param File File where this member is declared.
206  /// \param LineNo Line number.
207  /// \param Ty Type of the static member.
208  /// \param Flags Flags to encode member attribute, e.g. private.
209  /// \param Val Const initializer of the member.
211  DIFile *File, unsigned LineNo,
212  DIType *Ty, unsigned Flags,
213  llvm::Constant *Val);
214 
215  /// Create debugging information entry for Objective-C
216  /// instance variable.
217  /// \param Name Member name.
218  /// \param File File where this member is defined.
219  /// \param LineNo Line number.
220  /// \param SizeInBits Member size.
221  /// \param AlignInBits Member alignment.
222  /// \param OffsetInBits Member offset.
223  /// \param Flags Flags to encode member attribute, e.g. private
224  /// \param Ty Parent type.
225  /// \param PropertyNode Property associated with this ivar.
226  DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
227  uint64_t SizeInBits, uint64_t AlignInBits,
228  uint64_t OffsetInBits, unsigned Flags,
229  DIType *Ty, MDNode *PropertyNode);
230 
231  /// Create debugging information entry for Objective-C
232  /// property.
233  /// \param Name Property name.
234  /// \param File File where this property is defined.
235  /// \param LineNumber Line number.
236  /// \param GetterName Name of the Objective C property getter selector.
237  /// \param SetterName Name of the Objective C property setter selector.
238  /// \param PropertyAttributes Objective C property attributes.
239  /// \param Ty Type.
241  unsigned LineNumber,
242  StringRef GetterName,
243  StringRef SetterName,
244  unsigned PropertyAttributes, DIType *Ty);
245 
246  /// Create debugging information entry for a class.
247  /// \param Scope Scope in which this class is defined.
248  /// \param Name class name.
249  /// \param File File where this member is defined.
250  /// \param LineNumber Line number.
251  /// \param SizeInBits Member size.
252  /// \param AlignInBits Member alignment.
253  /// \param OffsetInBits Member offset.
254  /// \param Flags Flags to encode member attribute, e.g. private
255  /// \param Elements class members.
256  /// \param VTableHolder Debug info of the base class that contains vtable
257  /// for this type. This is used in
258  /// DW_AT_containing_type. See DWARF documentation
259  /// for more info.
260  /// \param TemplateParms Template type parameters.
261  /// \param UniqueIdentifier A unique identifier for the class.
263  DIFile *File, unsigned LineNumber,
264  uint64_t SizeInBits, uint64_t AlignInBits,
265  uint64_t OffsetInBits, unsigned Flags,
266  DIType *DerivedFrom, DINodeArray Elements,
267  DIType *VTableHolder = nullptr,
268  MDNode *TemplateParms = nullptr,
269  StringRef UniqueIdentifier = "");
270 
271  /// Create debugging information entry for a struct.
272  /// \param Scope Scope in which this struct is defined.
273  /// \param Name Struct name.
274  /// \param File File where this member is defined.
275  /// \param LineNumber Line number.
276  /// \param SizeInBits Member size.
277  /// \param AlignInBits Member alignment.
278  /// \param Flags Flags to encode member attribute, e.g. private
279  /// \param Elements Struct elements.
280  /// \param RunTimeLang Optional parameter, Objective-C runtime version.
281  /// \param UniqueIdentifier A unique identifier for the struct.
283  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
284  uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
285  DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
286  DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
287 
288  /// Create debugging information entry for an union.
289  /// \param Scope Scope in which this union is defined.
290  /// \param Name Union name.
291  /// \param File File where this member is defined.
292  /// \param LineNumber Line number.
293  /// \param SizeInBits Member size.
294  /// \param AlignInBits Member alignment.
295  /// \param Flags Flags to encode member attribute, e.g. private
296  /// \param Elements Union elements.
297  /// \param RunTimeLang Optional parameter, Objective-C runtime version.
298  /// \param UniqueIdentifier A unique identifier for the union.
300  DIFile *File, unsigned LineNumber,
301  uint64_t SizeInBits, uint64_t AlignInBits,
302  unsigned Flags, DINodeArray Elements,
303  unsigned RunTimeLang = 0,
304  StringRef UniqueIdentifier = "");
305 
306  /// Create debugging information for template
307  /// type parameter.
308  /// \param Scope Scope in which this type is defined.
309  /// \param Name Type parameter name.
310  /// \param Ty Parameter type.
313 
314  /// Create debugging information for template
315  /// value parameter.
316  /// \param Scope Scope in which this type is defined.
317  /// \param Name Value parameter name.
318  /// \param Ty Parameter type.
319  /// \param Val Constant parameter value.
321  StringRef Name,
322  DIType *Ty,
323  Constant *Val);
324 
325  /// Create debugging information for a template template parameter.
326  /// \param Scope Scope in which this type is defined.
327  /// \param Name Value parameter name.
328  /// \param Ty Parameter type.
329  /// \param Val The fully qualified name of the template.
331  StringRef Name,
332  DIType *Ty,
333  StringRef Val);
334 
335  /// Create debugging information for a template parameter pack.
336  /// \param Scope Scope in which this type is defined.
337  /// \param Name Value parameter name.
338  /// \param Ty Parameter type.
339  /// \param Val An array of types in the pack.
341  StringRef Name,
342  DIType *Ty,
343  DINodeArray Val);
344 
345  /// Create debugging information entry for an array.
346  /// \param Size Array size.
347  /// \param AlignInBits Alignment.
348  /// \param Ty Element type.
349  /// \param Subscripts Subscripts.
350  DICompositeType *createArrayType(uint64_t Size, uint64_t AlignInBits,
351  DIType *Ty, DINodeArray Subscripts);
352 
353  /// Create debugging information entry for a vector type.
354  /// \param Size Array size.
355  /// \param AlignInBits Alignment.
356  /// \param Ty Element type.
357  /// \param Subscripts Subscripts.
358  DICompositeType *createVectorType(uint64_t Size, uint64_t AlignInBits,
359  DIType *Ty, DINodeArray Subscripts);
360 
361  /// Create debugging information entry for an
362  /// enumeration.
363  /// \param Scope Scope in which this enumeration is defined.
364  /// \param Name Union name.
365  /// \param File File where this member is defined.
366  /// \param LineNumber Line number.
367  /// \param SizeInBits Member size.
368  /// \param AlignInBits Member alignment.
369  /// \param Elements Enumeration elements.
370  /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
371  /// \param UniqueIdentifier A unique identifier for the enum.
373  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
374  uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
375  DIType *UnderlyingType, StringRef UniqueIdentifier = "");
376 
377  /// Create subroutine type.
378  /// \param File File in which this subroutine is defined.
379  /// \param ParameterTypes An array of subroutine parameter types. This
380  /// includes return type at 0th index.
381  /// \param Flags E.g.: LValueReference.
382  /// These flags are used to emit dwarf attributes.
384  DITypeRefArray ParameterTypes,
385  unsigned Flags = 0);
386 
387  /// Create a new DIType* with "artificial" flag set.
389 
390  /// Create a new DIType* with the "object pointer"
391  /// flag set.
393 
394  /// Create a permanent forward-declared type.
396  DIScope *Scope, DIFile *F, unsigned Line,
397  unsigned RuntimeLang = 0,
398  uint64_t SizeInBits = 0,
399  uint64_t AlignInBits = 0,
400  StringRef UniqueIdentifier = "");
401 
402  /// Create a temporary forward-declared type.
404  unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
405  unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
406  uint64_t AlignInBits = 0, unsigned Flags = DINode::FlagFwdDecl,
407  StringRef UniqueIdentifier = "");
408 
409  /// Retain DIType* in a module even if it is not referenced
410  /// through debug info anchors.
411  void retainType(DIType *T);
412 
413  /// Create unspecified parameter type
414  /// for a subroutine type.
416 
417  /// Get a DINodeArray, create one if required.
418  DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
419 
420  /// Get a DITypeRefArray, create one if required.
422 
423  /// Create a descriptor for a value range. This
424  /// implicitly uniques the values returned.
425  DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
426 
427  /// Create a new descriptor for the specified
428  /// variable.
429  /// \param Context Variable scope.
430  /// \param Name Name of the variable.
431  /// \param LinkageName Mangled name of the variable.
432  /// \param File File where this variable is defined.
433  /// \param LineNo Line number.
434  /// \param Ty Variable Type.
435  /// \param isLocalToUnit Boolean flag indicate whether this variable is
436  /// externally visible or not.
437  /// \param Val llvm::Value of the variable.
438  /// \param Decl Reference to the corresponding declaration.
441  unsigned LineNo, DIType *Ty,
442  bool isLocalToUnit,
443  llvm::Constant *Val,
444  MDNode *Decl = nullptr);
445 
446  /// Identical to createGlobalVariable
447  /// except that the resulting DbgNode is temporary and meant to be RAUWed.
449  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
450  unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val,
451  MDNode *Decl = nullptr);
452 
453  /// Create a new descriptor for the specified
454  /// local variable.
455  /// \param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
456  /// DW_TAG_arg_variable.
457  /// \param Scope Variable scope.
458  /// \param Name Variable name.
459  /// \param File File where this variable is defined.
460  /// \param LineNo Line number.
461  /// \param Ty Variable Type
462  /// \param AlwaysPreserve Boolean. Set to true if debug info for this
463  /// variable should be preserved in optimized build.
464  /// \param Flags Flags, e.g. artificial variable.
465  /// \param ArgNo If this variable is an argument then this argument's
466  /// number. 1 indicates 1st argument.
468  StringRef Name, DIFile *File,
469  unsigned LineNo, DIType *Ty,
470  bool AlwaysPreserve = false,
471  unsigned Flags = 0,
472  unsigned ArgNo = 0);
473 
474  /// Create a new descriptor for the specified
475  /// variable which has a complex address expression for its address.
476  /// \param Addr An array of complex address operations.
479 
480  /// Create a descriptor to describe one part
481  /// of aggregate variable that is fragmented across multiple Values.
482  ///
483  /// \param OffsetInBits Offset of the piece in bits.
484  /// \param SizeInBits Size of the piece in bits.
485  DIExpression *createBitPieceExpression(unsigned OffsetInBits,
486  unsigned SizeInBits);
487 
488  /// Create a new descriptor for the specified subprogram.
489  /// See comments in DISubprogram* for descriptions of these fields.
490  /// \param Scope Function scope.
491  /// \param Name Function name.
492  /// \param LinkageName Mangled function name.
493  /// \param File File where this variable is defined.
494  /// \param LineNo Line number.
495  /// \param Ty Function type.
496  /// \param isLocalToUnit True if this function is not externally visible.
497  /// \param isDefinition True if this is a function definition.
498  /// \param ScopeLine Set to the beginning of the scope this starts
499  /// \param Flags e.g. is this function prototyped or not.
500  /// These flags are used to emit dwarf attributes.
501  /// \param isOptimized True if optimization is ON.
502  /// \param Fn llvm::Function pointer.
503  /// \param TParam Function template parameters.
504  DISubprogram *
506  DIFile *File, unsigned LineNo, DISubroutineType *Ty,
507  bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
508  unsigned Flags = 0, bool isOptimized = false,
509  Function *Fn = nullptr, MDNode *TParam = nullptr,
510  MDNode *Decl = nullptr);
511 
512  /// Identical to createFunction,
513  /// except that the resulting DbgNode is meant to be RAUWed.
516  unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
517  bool isDefinition, unsigned ScopeLine, unsigned Flags = 0,
518  bool isOptimized = false, Function *Fn = nullptr,
519  MDNode *TParam = nullptr, MDNode *Decl = nullptr);
520 
521  /// FIXME: this is added for dragonegg. Once we update dragonegg
522  /// to call resolve function, this will be removed.
523  DISubprogram *
525  DIFile *File, unsigned LineNo, DISubroutineType *Ty,
526  bool isLocalToUnit, bool isDefinition, unsigned ScopeLine,
527  unsigned Flags = 0, bool isOptimized = false,
528  Function *Fn = nullptr, MDNode *TParam = nullptr,
529  MDNode *Decl = nullptr);
530 
531  /// Create a new descriptor for the specified C++ method.
532  /// See comments in \a DISubprogram* for descriptions of these fields.
533  /// \param Scope Function scope.
534  /// \param Name Function name.
535  /// \param LinkageName Mangled function name.
536  /// \param File File where this variable is defined.
537  /// \param LineNo Line number.
538  /// \param Ty Function type.
539  /// \param isLocalToUnit True if this function is not externally visible..
540  /// \param isDefinition True if this is a function definition.
541  /// \param Virtuality Attributes describing virtualness. e.g. pure
542  /// virtual function.
543  /// \param VTableIndex Index no of this method in virtual table.
544  /// \param VTableHolder Type that holds vtable.
545  /// \param Flags e.g. is this function prototyped or not.
546  /// This flags are used to emit dwarf attributes.
547  /// \param isOptimized True if optimization is ON.
548  /// \param Fn llvm::Function pointer.
549  /// \param TParam Function template parameters.
550  DISubprogram *
552  DIFile *File, unsigned LineNo, DISubroutineType *Ty,
553  bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0,
554  unsigned VTableIndex = 0, DIType *VTableHolder = nullptr,
555  unsigned Flags = 0, bool isOptimized = false,
556  Function *Fn = nullptr, MDNode *TParam = nullptr);
557 
558  /// This creates new descriptor for a namespace with the specified
559  /// parent scope.
560  /// \param Scope Namespace scope
561  /// \param Name Name of this namespace
562  /// \param File Source file
563  /// \param LineNo Line number
565  unsigned LineNo);
566 
567  /// This creates new descriptor for a module with the specified
568  /// parent scope.
569  /// \param Scope Parent scope
570  /// \param Name Name of this module
571  /// \param ConfigurationMacros
572  /// A space-separated shell-quoted list of -D macro
573  /// definitions as they would appear on a command line.
574  /// \param IncludePath The path to the module map file.
575  /// \param ISysRoot The clang system root (value of -isysroot).
577  StringRef ConfigurationMacros,
578  StringRef IncludePath,
579  StringRef ISysRoot);
580 
581  /// This creates a descriptor for a lexical block with a new file
582  /// attached. This merely extends the existing
583  /// lexical block as it crosses a file.
584  /// \param Scope Lexical block.
585  /// \param File Source file.
586  /// \param Discriminator DWARF path discriminator value.
588  unsigned Discriminator = 0);
589 
590  /// This creates a descriptor for a lexical block with the
591  /// specified parent context.
592  /// \param Scope Parent lexical scope.
593  /// \param File Source file.
594  /// \param Line Line number.
595  /// \param Col Column number.
597  unsigned Line, unsigned Col);
598 
599  /// Create a descriptor for an imported module.
600  /// \param Context The scope this module is imported into
601  /// \param NS The namespace being imported here
602  /// \param Line Line number
604  unsigned Line);
605 
606  /// Create a descriptor for an imported module.
607  /// \param Context The scope this module is imported into
608  /// \param NS An aliased namespace
609  /// \param Line Line number
611  DIImportedEntity *NS, unsigned Line);
612 
613  /// Create a descriptor for an imported module.
614  /// \param Context The scope this module is imported into
615  /// \param M The module being imported here
616  /// \param Line Line number
618  unsigned Line);
619 
620  /// Create a descriptor for an imported function.
621  /// \param Context The scope this module is imported into
622  /// \param Decl The declaration (or definition) of a function, type, or
623  /// variable
624  /// \param Line Line number
626  unsigned Line,
627  StringRef Name = "");
628 
629  /// Insert a new llvm.dbg.declare intrinsic call.
630  /// \param Storage llvm::Value of the variable
631  /// \param VarInfo Variable's debug info descriptor.
632  /// \param Expr A complex location expression.
633  /// \param DL Debug info location.
634  /// \param InsertAtEnd Location for the new intrinsic.
636  DIExpression *Expr, const DILocation *DL,
637  BasicBlock *InsertAtEnd);
638 
639  /// Insert a new llvm.dbg.declare intrinsic call.
640  /// \param Storage llvm::Value of the variable
641  /// \param VarInfo Variable's debug info descriptor.
642  /// \param Expr A complex location expression.
643  /// \param DL Debug info location.
644  /// \param InsertBefore Location for the new intrinsic.
646  DIExpression *Expr, const DILocation *DL,
647  Instruction *InsertBefore);
648 
649  /// Insert a new llvm.dbg.value intrinsic call.
650  /// \param Val llvm::Value of the variable
651  /// \param Offset Offset
652  /// \param VarInfo Variable's debug info descriptor.
653  /// \param Expr A complex location expression.
654  /// \param DL Debug info location.
655  /// \param InsertAtEnd Location for the new intrinsic.
656  Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
657  DILocalVariable *VarInfo,
658  DIExpression *Expr,
659  const DILocation *DL,
660  BasicBlock *InsertAtEnd);
661 
662  /// Insert a new llvm.dbg.value intrinsic call.
663  /// \param Val llvm::Value of the variable
664  /// \param Offset Offset
665  /// \param VarInfo Variable's debug info descriptor.
666  /// \param Expr A complex location expression.
667  /// \param DL Debug info location.
668  /// \param InsertBefore Location for the new intrinsic.
669  Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
670  DILocalVariable *VarInfo,
671  DIExpression *Expr,
672  const DILocation *DL,
673  Instruction *InsertBefore);
674 
675  /// Replace the vtable holder in the given composite type.
676  ///
677  /// If this creates a self reference, it may orphan some unresolved cycles
678  /// in the operands of \c T, so \a DIBuilder needs to track that.
680  DICompositeType *VTableHolder);
681 
682  /// Replace arrays on a composite type.
683  ///
684  /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
685  /// has a self-reference -- \a DIBuilder needs to track the array to
686  /// resolve cycles.
687  void replaceArrays(DICompositeType *&T, DINodeArray Elements,
688  DINodeArray TParems = DINodeArray());
689 
690  /// Replace a temporary node.
691  ///
692  /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
693  /// Replacement.
694  ///
695  /// If \c Replacement is the same as \c N.get(), instead call \a
696  /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
697  /// have a different address, so we return the final address.
698  template <class NodeTy>
699  NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
700  if (N.get() == Replacement)
701  return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
702 
703  N->replaceAllUsesWith(Replacement);
704  return Replacement;
705  }
706  };
707 } // end namespace llvm
708 
709 #endif
void finalize()
Construct any deferred debug info descriptors.
Definition: DIBuilder.cpp:75
DIDerivedType * createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType *Ty, MDNode *PropertyNode)
Create debugging information entry for Objective-C instance variable.
Definition: DIBuilder.cpp:320
DICompositeType * createArrayType(uint64_t Size, uint64_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for an array.
Definition: DIBuilder.cpp:454
Various leaf nodes.
Definition: ISDOpcodes.h:60
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
DIDerivedType * createMemberPointerType(DIType *PointeeTy, DIType *Class, uint64_t SizeInBits, uint64_t AlignInBits=0)
Create debugging information entry for a pointer to member.
Definition: DIBuilder.cpp:248
DISubrange * getOrCreateSubrange(int64_t Lo, int64_t Count)
Create a descriptor for a value range.
Definition: DIBuilder.cpp:553
Metadata node.
Definition: Metadata.h:740
F(f)
Instruction * insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.value intrinsic call.
Definition: DIBuilder.cpp:811
DIType * createObjectPointerType(DIType *Ty)
Create a new DIType* with the "object pointer" flag set.
Definition: DIBuilder.cpp:489
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeRefArray, create one if required.
Definition: DIBuilder.cpp:542
Tagged DWARF-like metadata node.
DILexicalBlockFile * createLexicalBlockFile(DIScope *Scope, DIFile *File, unsigned Discriminator=0)
This creates a descriptor for a lexical block with a new file attached.
Definition: DIBuilder.cpp:721
DINodeArray getOrCreateArray(ArrayRef< Metadata * > Elements)
Get a DINodeArray, create one if required.
Definition: DIBuilder.cpp:538
DITemplateTypeParameter * createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty)
Create debugging information for template type parameter.
Definition: DIBuilder.cpp:342
Array subrange.
Instruction * insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.declare intrinsic call.
Definition: DIBuilder.cpp:764
DIDerivedType * createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, DIScope *Context)
Create debugging information entry for a typedef.
Definition: DIBuilder.cpp:264
DICompositeType * createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements, DIType *UnderlyingType, StringRef UniqueIdentifier="")
Create debugging information entry for an enumeration.
Definition: DIBuilder.cpp:438
DIBasicType * createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
Definition: DIBuilder.cpp:216
DICompositeType * createStructType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang=0, DIType *VTableHolder=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a struct.
Definition: DIBuilder.cpp:401
DIDerivedType * createInheritance(DIType *Ty, DIType *BaseTy, uint64_t BaseOffset, unsigned Flags)
Create debugging information entry to establish inheritance relationship between two types...
Definition: DIBuilder.cpp:281
Pointer union between a subclass of DINode and MDString.
DIEnumerator * createEnumerator(StringRef Name, int64_t Val)
Create a single enumerator value.
Definition: DIBuilder.cpp:211
Subprogram description.
DISubprogram * createTempFunctionFwdDecl(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags=0, bool isOptimized=false, Function *Fn=nullptr, MDNode *TParam=nullptr, MDNode *Decl=nullptr)
Identical to createFunction, except that the resulting DbgNode is meant to be RAUWed.
Definition: DIBuilder.cpp:669
DICompositeType * createReplaceableCompositeType(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint64_t AlignInBits=0, unsigned Flags=DINode::FlagFwdDecl, StringRef UniqueIdentifier="")
Create a temporary forward-declared type.
Definition: DIBuilder.cpp:522
Enumeration value.
DIExpression * createBitPieceExpression(unsigned OffsetInBits, unsigned SizeInBits)
Create a descriptor to describe one part of aggregate variable that is fragmented across multiple Val...
Definition: DIBuilder.cpp:626
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:31
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
Definition: Metadata.h:824
Debug location.
DIBasicType * createNullPtrType()
Create C++11 nullptr type.
Definition: DIBuilder.cpp:221
DIType * createArtificialType(DIType *Ty)
Create a new DIType* with "artificial" flag set.
Definition: DIBuilder.cpp:482
static std::enable_if< std::is_base_of< MDNode, T >::value, T * >::type replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
Definition: Metadata.h:856
void replaceVTableHolder(DICompositeType *&T, DICompositeType *VTableHolder)
Replace the vtable holder in the given composite type.
Definition: DIBuilder.cpp:835
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:41
DILocalVariable * createLocalVariable(unsigned Tag, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, unsigned Flags=0, unsigned ArgNo=0)
Create a new descriptor for the specified local variable.
Definition: DIBuilder.cpp:593
This is an important base class in LLVM.
Definition: Constant.h:41
void replaceArrays(DICompositeType *&T, DINodeArray Elements, DINodeArray TParems=DINodeArray())
Replace arrays on a composite type.
Definition: DIBuilder.cpp:855
DIGlobalVariable * createGlobalVariable(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val, MDNode *Decl=nullptr)
Create a new descriptor for the specified variable.
Definition: DIBuilder.cpp:566
DIImportedEntity * createImportedDeclaration(DIScope *Context, DINode *Decl, unsigned Line, StringRef Name="")
Create a descriptor for an imported function.
Definition: DIBuilder.cpp:196
DIBasicType * createUnspecifiedParameter()
Create unspecified parameter type for a subroutine type.
Definition: DIBuilder.cpp:502
DICompileUnit * createCompileUnit(unsigned Lang, StringRef File, StringRef Dir, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RV, StringRef SplitName=StringRef(), DebugEmissionKind Kind=FullDebug, uint64_t DWOId=0, bool EmitDebugInfo=true)
A CompileUnit provides an anchor for all debugging information generated during this instance of comp...
Definition: DIBuilder.cpp:136
DIDerivedType * createReferenceType(unsigned Tag, DIType *RTy)
Create debugging information entry for a c++ style reference or rvalue reference type.
Definition: DIBuilder.cpp:258
DIBasicType * createBasicType(StringRef Name, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Encoding)
Create debugging information entry for a basic type.
Definition: DIBuilder.cpp:225
An imported module (C++ using directive or similar).
Base class for scope-like contexts.
DICompositeType * createUnionType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DINodeArray Elements, unsigned RunTimeLang=0, StringRef UniqueIdentifier="")
Create debugging information entry for an union.
Definition: DIBuilder.cpp:417
DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, Constant *Val)
Create debugging information for template value parameter.
Definition: DIBuilder.cpp:358
void retainType(DIType *T)
Retain DIType* in a module even if it is not referenced through debug info anchors.
Definition: DIBuilder.cpp:497
Base class for types.
DITemplateValueParameter * createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, DINodeArray Val)
Create debugging information for a template parameter pack.
Definition: DIBuilder.cpp:374
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
DIGlobalVariable * createTempGlobalVariableFwdDecl(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val, MDNode *Decl=nullptr)
Identical to createGlobalVariable except that the resulting DbgNode is temporary and meant to be RAUW...
Definition: DIBuilder.cpp:580
DIExpression * createExpression(ArrayRef< uint64_t > Addr=None)
Create a new descriptor for the specified variable which has a complex address expression for its add...
Definition: DIBuilder.cpp:616
DICompositeType * createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint64_t AlignInBits=0, StringRef UniqueIdentifier="")
Create a permanent forward-declared type.
Definition: DIBuilder.cpp:505
DWARF expression.
DIDerivedType * createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, unsigned Flags, llvm::Constant *Val)
Create debugging information entry for a C++ static data member.
Definition: DIBuilder.cpp:308
DIImportedEntity * createImportedModule(DIScope *Context, DINamespace *NS, unsigned Line)
Create a descriptor for an imported module.
Definition: DIBuilder.cpp:176
DICompositeType * createVectorType(uint64_t Size, uint64_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for a vector type.
Definition: DIBuilder.cpp:464
DISubprogram * createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality=0, unsigned VTableIndex=0, DIType *VTableHolder=nullptr, unsigned Flags=0, bool isOptimized=false, Function *Fn=nullptr, MDNode *TParam=nullptr)
Create a new descriptor for the specified C++ method.
Definition: DIBuilder.cpp:684
A (clang) module that has been imported by the compile unit.
DIObjCProperty * createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber, StringRef GetterName, StringRef SetterName, unsigned PropertyAttributes, DIType *Ty)
Create debugging information entry for Objective-C property.
Definition: DIBuilder.cpp:333
DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val)
Create debugging information for a template template parameter.
Definition: DIBuilder.cpp:366
Type array for a subprogram.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1030
NodeTy * replaceTemporary(TempMDNode &&N, NodeTy *Replacement)
Replace a temporary node.
Definition: DIBuilder.h:699
DISubroutineType * createSubroutineType(DIFile *File, DITypeRefArray ParameterTypes, unsigned Flags=0)
Create subroutine type.
Definition: DIBuilder.cpp:432
DILexicalBlock * createLexicalBlock(DIScope *Scope, DIFile *File, unsigned Line, unsigned Col)
This creates a descriptor for a lexical block with the specified parent context.
Definition: DIBuilder.cpp:727
#define N
DINamespace * createNameSpace(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo)
This creates new descriptor for a namespace with the specified parent scope.
Definition: DIBuilder.cpp:707
const ARM::ArchExtKind Kind
DIModule * createModule(DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef ISysRoot)
This creates new descriptor for a module with the specified parent scope.
Definition: DIBuilder.cpp:713
LLVM Value Representation.
Definition: Value.h:69
DICompositeType * createClassType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType *DerivedFrom, DINodeArray Elements, DIType *VTableHolder=nullptr, MDNode *TemplateParms=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a class.
Definition: DIBuilder.cpp:381
DIDerivedType * createMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType *Ty)
Create debugging information entry for a member.
Definition: DIBuilder.cpp:290
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
DIDerivedType * createQualifiedType(unsigned Tag, DIType *FromTy)
Create debugging information entry for a qualified type, e.g.
Definition: DIBuilder.cpp:233
DIDerivedType * createFriend(DIType *Ty, DIType *FriendTy)
Create debugging information entry for a 'friend'.
Definition: DIBuilder.cpp:273
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags=0, bool isOptimized=false, Function *Fn=nullptr, MDNode *TParam=nullptr, MDNode *Decl=nullptr)
Create a new descriptor for the specified subprogram.
Definition: DIBuilder.cpp:647
DIDerivedType * createPointerType(DIType *PointeeTy, uint64_t SizeInBits, uint64_t AlignInBits=0, StringRef Name="")
Create debugging information entry for a pointer.
Definition: DIBuilder.cpp:238
Basic type, like 'int' or 'float'.
DIFile * createFile(StringRef Filename, StringRef Directory)
Create a file descriptor to hold debugging information for a file.
Definition: DIBuilder.cpp:207