DIBuilder: Delete dead code, NFC
[oota-llvm.git] / include / llvm / IR / DIBuilder.h
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/ValueHandle.h"
22 #include "llvm/Support/DataTypes.h"
23
24 namespace llvm {
25   class BasicBlock;
26   class Instruction;
27   class Function;
28   class Module;
29   class Value;
30   class LLVMContext;
31   class MDNode;
32   class StringRef;
33   class DIBasicType;
34   class DICompileUnit;
35   class DICompositeType;
36   class DIDerivedType;
37   class DIDescriptor;
38   class DIFile;
39   class DIEnumerator;
40   class DIType;
41   class DIGlobalVariable;
42   class DIImportedEntity;
43   class DINameSpace;
44   class DIVariable;
45   class DISubrange;
46   class DILexicalBlockFile;
47   class DILexicalBlock;
48   class DIScope;
49   class DISubprogram;
50   class DITemplateTypeParameter;
51   class DITemplateValueParameter;
52   class DIObjCProperty;
53
54   class DIBuilder {
55     private:
56     Module &M;
57     LLVMContext &VMContext;
58
59     MDNode *TempEnumTypes;
60     MDNode *TempRetainTypes;
61     MDNode *TempSubprograms;
62     MDNode *TempGVs;
63     MDNode *TempImportedModules;
64
65     Function *DeclareFn;     // llvm.dbg.declare
66     Function *ValueFn;       // llvm.dbg.value
67
68     SmallVector<Value *, 4> AllEnumTypes;
69     /// Use TrackingVH to collect RetainTypes, since they can be updated
70     /// later on.
71     SmallVector<TrackingVH<MDNode>, 4> AllRetainTypes;
72     SmallVector<Value *, 4> AllSubprograms;
73     SmallVector<Value *, 4> AllGVs;
74     SmallVector<TrackingVH<MDNode>, 4> AllImportedModules;
75
76     // Private use for multiple types of template parameters.
77     DITemplateValueParameter
78     createTemplateValueParameter(unsigned Tag, DIDescriptor Scope,
79                                  StringRef Name, DIType Ty, Value *Val,
80                                  MDNode *File = nullptr, unsigned LineNo = 0,
81                                  unsigned ColumnNo = 0);
82
83     DIBuilder(const DIBuilder &) LLVM_DELETED_FUNCTION;
84     void operator=(const DIBuilder &) LLVM_DELETED_FUNCTION;
85
86     public:
87     explicit DIBuilder(Module &M);
88     enum ComplexAddrKind { OpPlus=1, OpDeref, OpPiece };
89     enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
90
91     /// finalize - Construct any deferred debug info descriptors.
92     void finalize();
93
94     /// createCompileUnit - A CompileUnit provides an anchor for all debugging
95     /// information generated during this instance of compilation.
96     /// @param Lang     Source programming language, eg. dwarf::DW_LANG_C99
97     /// @param File     File name
98     /// @param Dir      Directory
99     /// @param Producer Identify the producer of debugging information and code.
100     ///                 Usually this is a compiler version string.
101     /// @param isOptimized A boolean flag which indicates whether optimization
102     ///                    is ON or not.
103     /// @param Flags    This string lists command line options. This string is
104     ///                 directly embedded in debug info output which may be used
105     ///                 by a tool analyzing generated debugging information.
106     /// @param RV       This indicates runtime version for languages like
107     ///                 Objective-C.
108     /// @param SplitName The name of the file that we'll split debug info out
109     ///                  into.
110     /// @param Kind     The kind of debug information to generate.
111     /// @param EmitDebugInfo   A boolean flag which indicates whether debug
112     ///                        information should be written to the final
113     ///                        output or not. When this is false, debug
114     ///                        information annotations will be present in
115     ///                        the IL but they are not written to the final
116     ///                        assembly or object file. This supports tracking
117     ///                        source location information in the back end
118     ///                        without actually changing the output (e.g.,
119     ///                        when using optimization remarks).
120     DICompileUnit createCompileUnit(unsigned Lang, StringRef File,
121                                     StringRef Dir, StringRef Producer,
122                                     bool isOptimized, StringRef Flags,
123                                     unsigned RV,
124                                     StringRef SplitName = StringRef(),
125                                     DebugEmissionKind Kind = FullDebug,
126                                     bool EmitDebugInfo = true);
127
128     /// createFile - Create a file descriptor to hold debugging information
129     /// for a file.
130     DIFile createFile(StringRef Filename, StringRef Directory);
131
132     /// createEnumerator - Create a single enumerator value.
133     DIEnumerator createEnumerator(StringRef Name, int64_t Val);
134
135     /// \brief Create a DWARF unspecified type.
136     DIBasicType createUnspecifiedType(StringRef Name);
137
138     /// \brief Create C++11 nullptr type.
139     DIBasicType createNullPtrType();
140
141     /// createBasicType - Create debugging information entry for a basic
142     /// type.
143     /// @param Name        Type name.
144     /// @param SizeInBits  Size of the type.
145     /// @param AlignInBits Type alignment.
146     /// @param Encoding    DWARF encoding code, e.g. dwarf::DW_ATE_float.
147     DIBasicType createBasicType(StringRef Name, uint64_t SizeInBits,
148                                 uint64_t AlignInBits, unsigned Encoding);
149
150     /// createQualifiedType - Create debugging information entry for a qualified
151     /// type, e.g. 'const int'.
152     /// @param Tag         Tag identifing type, e.g. dwarf::TAG_volatile_type
153     /// @param FromTy      Base Type.
154     DIDerivedType createQualifiedType(unsigned Tag, DIType FromTy);
155
156     /// createPointerType - Create debugging information entry for a pointer.
157     /// @param PointeeTy   Type pointed by this pointer.
158     /// @param SizeInBits  Size.
159     /// @param AlignInBits Alignment. (optional)
160     /// @param Name        Pointer type name. (optional)
161     DIDerivedType
162     createPointerType(DIType PointeeTy, uint64_t SizeInBits,
163                       uint64_t AlignInBits = 0, StringRef Name = StringRef());
164
165     /// \brief Create debugging information entry for a pointer to member.
166     /// @param PointeeTy Type pointed to by this pointer.
167     /// @param Class Type for which this pointer points to members of.
168     DIDerivedType createMemberPointerType(DIType PointeeTy, DIType Class);
169
170     /// createReferenceType - Create debugging information entry for a c++
171     /// style reference or rvalue reference type.
172     DIDerivedType createReferenceType(unsigned Tag, DIType RTy);
173
174     /// createTypedef - Create debugging information entry for a typedef.
175     /// @param Ty          Original type.
176     /// @param Name        Typedef name.
177     /// @param File        File where this type is defined.
178     /// @param LineNo      Line number.
179     /// @param Context     The surrounding context for the typedef.
180     DIDerivedType createTypedef(DIType Ty, StringRef Name, DIFile File,
181                                 unsigned LineNo, DIDescriptor Context);
182
183     /// createFriend - Create debugging information entry for a 'friend'.
184     DIDerivedType createFriend(DIType Ty, DIType FriendTy);
185
186     /// createInheritance - Create debugging information entry to establish
187     /// inheritance relationship between two types.
188     /// @param Ty           Original type.
189     /// @param BaseTy       Base type. Ty is inherits from base.
190     /// @param BaseOffset   Base offset.
191     /// @param Flags        Flags to describe inheritance attribute,
192     ///                     e.g. private
193     DIDerivedType createInheritance(DIType Ty, DIType BaseTy,
194                                     uint64_t BaseOffset, unsigned Flags);
195
196     /// createMemberType - Create debugging information entry for a member.
197     /// @param Scope        Member scope.
198     /// @param Name         Member name.
199     /// @param File         File where this member is defined.
200     /// @param LineNo       Line number.
201     /// @param SizeInBits   Member size.
202     /// @param AlignInBits  Member alignment.
203     /// @param OffsetInBits Member offset.
204     /// @param Flags        Flags to encode member attribute, e.g. private
205     /// @param Ty           Parent type.
206     DIDerivedType
207     createMemberType(DIDescriptor Scope, StringRef Name, DIFile File,
208                      unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits,
209                      uint64_t OffsetInBits, unsigned Flags, DIType Ty);
210
211     /// createStaticMemberType - Create debugging information entry for a
212     /// C++ static data member.
213     /// @param Scope      Member scope.
214     /// @param Name       Member name.
215     /// @param File       File where this member is declared.
216     /// @param LineNo     Line number.
217     /// @param Ty         Type of the static member.
218     /// @param Flags      Flags to encode member attribute, e.g. private.
219     /// @param Val        Const initializer of the member.
220     DIDerivedType
221     createStaticMemberType(DIDescriptor Scope, StringRef Name,
222                            DIFile File, unsigned LineNo, DIType Ty,
223                            unsigned Flags, llvm::Value *Val);
224
225     /// createObjCIVar - Create debugging information entry for Objective-C
226     /// instance variable.
227     /// @param Name         Member name.
228     /// @param File         File where this member is defined.
229     /// @param LineNo       Line number.
230     /// @param SizeInBits   Member size.
231     /// @param AlignInBits  Member alignment.
232     /// @param OffsetInBits Member offset.
233     /// @param Flags        Flags to encode member attribute, e.g. private
234     /// @param Ty           Parent type.
235     /// @param PropertyNode Property associated with this ivar.
236     DIDerivedType createObjCIVar(StringRef Name, DIFile File,
237                                  unsigned LineNo, uint64_t SizeInBits,
238                                  uint64_t AlignInBits, uint64_t OffsetInBits,
239                                  unsigned Flags, DIType Ty,
240                                  MDNode *PropertyNode);
241
242     /// createObjCProperty - Create debugging information entry for Objective-C
243     /// property.
244     /// @param Name         Property name.
245     /// @param File         File where this property is defined.
246     /// @param LineNumber   Line number.
247     /// @param GetterName   Name of the Objective C property getter selector.
248     /// @param SetterName   Name of the Objective C property setter selector.
249     /// @param PropertyAttributes Objective C property attributes.
250     /// @param Ty           Type.
251     DIObjCProperty createObjCProperty(StringRef Name,
252                                       DIFile File, unsigned LineNumber,
253                                       StringRef GetterName,
254                                       StringRef SetterName,
255                                       unsigned PropertyAttributes,
256                                       DIType Ty);
257
258     /// createClassType - Create debugging information entry for a class.
259     /// @param Scope        Scope in which this class is defined.
260     /// @param Name         class name.
261     /// @param File         File where this member is defined.
262     /// @param LineNumber   Line number.
263     /// @param SizeInBits   Member size.
264     /// @param AlignInBits  Member alignment.
265     /// @param OffsetInBits Member offset.
266     /// @param Flags        Flags to encode member attribute, e.g. private
267     /// @param Elements     class members.
268     /// @param VTableHolder Debug info of the base class that contains vtable
269     ///                     for this type. This is used in
270     ///                     DW_AT_containing_type. See DWARF documentation
271     ///                     for more info.
272     /// @param TemplateParms Template type parameters.
273     /// @param UniqueIdentifier A unique identifier for the class.
274     DICompositeType createClassType(DIDescriptor Scope, StringRef Name,
275                                     DIFile File, unsigned LineNumber,
276                                     uint64_t SizeInBits, uint64_t AlignInBits,
277                                     uint64_t OffsetInBits, unsigned Flags,
278                                     DIType DerivedFrom, DIArray Elements,
279                                     DIType VTableHolder = DIType(),
280                                     MDNode *TemplateParms = nullptr,
281                                     StringRef UniqueIdentifier = StringRef());
282
283     /// createStructType - Create debugging information entry for a struct.
284     /// @param Scope        Scope in which this struct is defined.
285     /// @param Name         Struct name.
286     /// @param File         File where this member is defined.
287     /// @param LineNumber   Line number.
288     /// @param SizeInBits   Member size.
289     /// @param AlignInBits  Member alignment.
290     /// @param Flags        Flags to encode member attribute, e.g. private
291     /// @param Elements     Struct elements.
292     /// @param RunTimeLang  Optional parameter, Objective-C runtime version.
293     /// @param UniqueIdentifier A unique identifier for the struct.
294     DICompositeType createStructType(DIDescriptor Scope, StringRef Name,
295                                      DIFile File, unsigned LineNumber,
296                                      uint64_t SizeInBits, uint64_t AlignInBits,
297                                      unsigned Flags, DIType DerivedFrom,
298                                      DIArray Elements, unsigned RunTimeLang = 0,
299                                      DIType VTableHolder = DIType(),
300                                      StringRef UniqueIdentifier = StringRef());
301
302     /// createUnionType - Create debugging information entry for an union.
303     /// @param Scope        Scope in which this union is defined.
304     /// @param Name         Union name.
305     /// @param File         File where this member is defined.
306     /// @param LineNumber   Line number.
307     /// @param SizeInBits   Member size.
308     /// @param AlignInBits  Member alignment.
309     /// @param Flags        Flags to encode member attribute, e.g. private
310     /// @param Elements     Union elements.
311     /// @param RunTimeLang  Optional parameter, Objective-C runtime version.
312     /// @param UniqueIdentifier A unique identifier for the union.
313     DICompositeType createUnionType(
314         DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
315         uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
316         DIArray Elements, unsigned RunTimeLang = 0,
317         StringRef UniqueIdentifier = StringRef());
318
319     /// createTemplateTypeParameter - Create debugging information for template
320     /// type parameter.
321     /// @param Scope        Scope in which this type is defined.
322     /// @param Name         Type parameter name.
323     /// @param Ty           Parameter type.
324     /// @param File         File where this type parameter is defined.
325     /// @param LineNo       Line number.
326     /// @param ColumnNo     Column Number.
327     DITemplateTypeParameter
328     createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
329                                 MDNode *File = nullptr, unsigned LineNo = 0,
330                                 unsigned ColumnNo = 0);
331
332     /// createTemplateValueParameter - Create debugging information for template
333     /// value parameter.
334     /// @param Scope        Scope in which this type is defined.
335     /// @param Name         Value parameter name.
336     /// @param Ty           Parameter type.
337     /// @param Val          Constant parameter value.
338     /// @param File         File where this type parameter is defined.
339     /// @param LineNo       Line number.
340     /// @param ColumnNo     Column Number.
341     DITemplateValueParameter
342     createTemplateValueParameter(DIDescriptor Scope, StringRef Name,
343                                  DIType Ty, Value *Val, MDNode *File = nullptr,
344                                  unsigned LineNo = 0, unsigned ColumnNo = 0);
345
346     /// \brief Create debugging information for a template template parameter.
347     /// @param Scope        Scope in which this type is defined.
348     /// @param Name         Value parameter name.
349     /// @param Ty           Parameter type.
350     /// @param Val          The fully qualified name of the template.
351     /// @param File         File where this type parameter is defined.
352     /// @param LineNo       Line number.
353     /// @param ColumnNo     Column Number.
354     DITemplateValueParameter
355     createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name,
356                                     DIType Ty, StringRef Val,
357                                     MDNode *File = nullptr, unsigned LineNo = 0,
358                                     unsigned ColumnNo = 0);
359
360     /// \brief Create debugging information for a template parameter pack.
361     /// @param Scope        Scope in which this type is defined.
362     /// @param Name         Value parameter name.
363     /// @param Ty           Parameter type.
364     /// @param Val          An array of types in the pack.
365     /// @param File         File where this type parameter is defined.
366     /// @param LineNo       Line number.
367     /// @param ColumnNo     Column Number.
368     DITemplateValueParameter
369     createTemplateParameterPack(DIDescriptor Scope, StringRef Name,
370                                 DIType Ty, DIArray Val, MDNode *File = nullptr,
371                                 unsigned LineNo = 0, unsigned ColumnNo = 0);
372
373     /// createArrayType - Create debugging information entry for an array.
374     /// @param Size         Array size.
375     /// @param AlignInBits  Alignment.
376     /// @param Ty           Element type.
377     /// @param Subscripts   Subscripts.
378     DICompositeType createArrayType(uint64_t Size, uint64_t AlignInBits,
379                                     DIType Ty, DIArray Subscripts);
380
381     /// createVectorType - Create debugging information entry for a vector type.
382     /// @param Size         Array size.
383     /// @param AlignInBits  Alignment.
384     /// @param Ty           Element type.
385     /// @param Subscripts   Subscripts.
386     DICompositeType createVectorType(uint64_t Size, uint64_t AlignInBits,
387                                      DIType Ty, DIArray Subscripts);
388
389     /// createEnumerationType - Create debugging information entry for an
390     /// enumeration.
391     /// @param Scope          Scope in which this enumeration is defined.
392     /// @param Name           Union name.
393     /// @param File           File where this member is defined.
394     /// @param LineNumber     Line number.
395     /// @param SizeInBits     Member size.
396     /// @param AlignInBits    Member alignment.
397     /// @param Elements       Enumeration elements.
398     /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
399     /// @param UniqueIdentifier A unique identifier for the enum.
400     DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name,
401         DIFile File, unsigned LineNumber, uint64_t SizeInBits,
402         uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType,
403         StringRef UniqueIdentifier = StringRef());
404
405     /// createSubroutineType - Create subroutine type.
406     /// @param File            File in which this subroutine is defined.
407     /// @param ParameterTypes  An array of subroutine parameter types. This
408     ///                        includes return type at 0th index.
409     /// @param Flags           E.g.: LValueReference.
410     ///                        These flags are used to emit dwarf attributes.
411     DISubroutineType createSubroutineType(DIFile File,
412                                           DITypeArray ParameterTypes,
413                                           unsigned Flags = 0);
414
415     /// createArtificialType - Create a new DIType with "artificial" flag set.
416     DIType createArtificialType(DIType Ty);
417
418     /// createObjectPointerType - Create a new DIType with the "object pointer"
419     /// flag set.
420     DIType createObjectPointerType(DIType Ty);
421
422     /// \brief Create a permanent forward-declared type.
423     DICompositeType createForwardDecl(unsigned Tag, StringRef Name,
424                                       DIDescriptor Scope, DIFile F,
425                                       unsigned Line, unsigned RuntimeLang = 0,
426                                       uint64_t SizeInBits = 0,
427                                       uint64_t AlignInBits = 0,
428                                       StringRef UniqueIdentifier = StringRef());
429
430     /// \brief Create a temporary forward-declared type.
431     DICompositeType createReplaceableForwardDecl(
432         unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F,
433         unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
434         uint64_t AlignInBits = 0, StringRef UniqueIdentifier = StringRef());
435
436     /// retainType - Retain DIType in a module even if it is not referenced
437     /// through debug info anchors.
438     void retainType(DIType T);
439
440     /// createUnspecifiedParameter - Create unspecified parameter type
441     /// for a subroutine type.
442     DIBasicType createUnspecifiedParameter();
443
444     /// getOrCreateArray - Get a DIArray, create one if required.
445     DIArray getOrCreateArray(ArrayRef<Value *> Elements);
446
447     /// getOrCreateTypeArray - Get a DITypeArray, create one if required.
448     DITypeArray getOrCreateTypeArray(ArrayRef<Value *> Elements);
449
450     /// getOrCreateSubrange - Create a descriptor for a value range.  This
451     /// implicitly uniques the values returned.
452     DISubrange getOrCreateSubrange(int64_t Lo, int64_t Count);
453
454     /// createGlobalVariable - Create a new descriptor for the specified global.
455     /// @param Name        Name of the variable.
456     /// @param File        File where this variable is defined.
457     /// @param LineNo      Line number.
458     /// @param Ty          Variable Type.
459     /// @param isLocalToUnit Boolean flag indicate whether this variable is
460     ///                      externally visible or not.
461     /// @param Val         llvm::Value of the variable.
462     DIGlobalVariable
463     createGlobalVariable(StringRef Name, DIFile File, unsigned LineNo,
464                          DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val);
465
466     /// \brief Create a new descriptor for the specified global.
467     /// @param Name        Name of the variable.
468     /// @param LinkageName Mangled variable name.
469     /// @param File        File where this variable is defined.
470     /// @param LineNo      Line number.
471     /// @param Ty          Variable Type.
472     /// @param isLocalToUnit Boolean flag indicate whether this variable is
473     ///                      externally visible or not.
474     /// @param Val         llvm::Value of the variable.
475     DIGlobalVariable
476     createGlobalVariable(StringRef Name, StringRef LinkageName, DIFile File,
477                          unsigned LineNo, DITypeRef Ty, bool isLocalToUnit,
478                          llvm::Value *Val);
479
480     /// createStaticVariable - Create a new descriptor for the specified
481     /// variable.
482     /// @param Context     Variable scope.
483     /// @param Name        Name of the variable.
484     /// @param LinkageName Mangled  name of the variable.
485     /// @param File        File where this variable is defined.
486     /// @param LineNo      Line number.
487     /// @param Ty          Variable Type.
488     /// @param isLocalToUnit Boolean flag indicate whether this variable is
489     ///                      externally visible or not.
490     /// @param Val         llvm::Value of the variable.
491     /// @param Decl        Reference to the corresponding declaration.
492     DIGlobalVariable
493     createStaticVariable(DIDescriptor Context, StringRef Name,
494                          StringRef LinkageName, DIFile File, unsigned LineNo,
495                          DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
496                          MDNode *Decl = nullptr);
497
498     /// createTempStaticVariableFwdDecl - Identical to createStaticVariable
499     /// except that the resulting DbgNode is temporary and meant to be RAUWed.
500     DIGlobalVariable
501     createTempStaticVariableFwdDecl(DIDescriptor Context, StringRef Name,
502                                     StringRef LinkageName, DIFile File,
503                                     unsigned LineNo, DITypeRef Ty,
504                                     bool isLocalToUnit, llvm::Value *Val,
505                                     MDNode *Decl = nullptr);
506
507
508     /// createLocalVariable - Create a new descriptor for the specified
509     /// local variable.
510     /// @param Tag         Dwarf TAG. Usually DW_TAG_auto_variable or
511     ///                    DW_TAG_arg_variable.
512     /// @param Scope       Variable scope.
513     /// @param Name        Variable name.
514     /// @param File        File where this variable is defined.
515     /// @param LineNo      Line number.
516     /// @param Ty          Variable Type
517     /// @param AlwaysPreserve Boolean. Set to true if debug info for this
518     ///                       variable should be preserved in optimized build.
519     /// @param Flags       Flags, e.g. artificial variable.
520     /// @param ArgNo       If this variable is an argument then this argument's
521     ///                    number. 1 indicates 1st argument.
522     DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
523                                    StringRef Name,
524                                    DIFile File, unsigned LineNo,
525                                    DITypeRef Ty, bool AlwaysPreserve = false,
526                                    unsigned Flags = 0,
527                                    unsigned ArgNo = 0);
528
529
530     /// createComplexVariable - Create a new descriptor for the specified
531     /// variable which has a complex address expression for its address.
532     /// @param Tag         Dwarf TAG. Usually DW_TAG_auto_variable or
533     ///                    DW_TAG_arg_variable.
534     /// @param Scope       Variable scope.
535     /// @param Name        Variable name.
536     /// @param F           File where this variable is defined.
537     /// @param LineNo      Line number.
538     /// @param Ty          Variable Type
539     /// @param Addr        An array of complex address operations.
540     /// @param ArgNo       If this variable is an argument then this argument's
541     ///                    number. 1 indicates 1st argument.
542     DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
543                                      StringRef Name, DIFile F, unsigned LineNo,
544                                      DITypeRef Ty, ArrayRef<Value *> Addr,
545                                      unsigned ArgNo = 0);
546
547     /// createVariablePiece - Create a descriptor to describe one part
548     /// of aggregate variable that is fragmented across multiple Values.
549     ///
550     /// @param Variable      Variable that is partially represented by this.
551     /// @param OffsetInBytes Offset of the piece in bytes.
552     /// @param SizeInBytes   Size of the piece in bytes.
553     DIVariable createVariablePiece(DIVariable Variable,
554                                    unsigned OffsetInBytes,
555                                    unsigned SizeInBytes);
556
557     /// createFunction - Create a new descriptor for the specified subprogram.
558     /// See comments in DISubprogram for descriptions of these fields.
559     /// @param Scope         Function scope.
560     /// @param Name          Function name.
561     /// @param LinkageName   Mangled function name.
562     /// @param File          File where this variable is defined.
563     /// @param LineNo        Line number.
564     /// @param Ty            Function type.
565     /// @param isLocalToUnit True if this function is not externally visible.
566     /// @param isDefinition  True if this is a function definition.
567     /// @param ScopeLine     Set to the beginning of the scope this starts
568     /// @param Flags         e.g. is this function prototyped or not.
569     ///                      These flags are used to emit dwarf attributes.
570     /// @param isOptimized   True if optimization is ON.
571     /// @param Fn            llvm::Function pointer.
572     /// @param TParam        Function template parameters.
573     DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
574                                 StringRef LinkageName,
575                                 DIFile File, unsigned LineNo,
576                                 DICompositeType Ty, bool isLocalToUnit,
577                                 bool isDefinition,
578                                 unsigned ScopeLine,
579                                 unsigned Flags = 0,
580                                 bool isOptimized = false,
581                                 Function *Fn = nullptr,
582                                 MDNode *TParam = nullptr,
583                                 MDNode *Decl = nullptr);
584
585     /// createTempFunctionFwdDecl - Identical to createFunction,
586     /// except that the resulting DbgNode is meant to be RAUWed.
587     DISubprogram createTempFunctionFwdDecl(DIDescriptor Scope, StringRef Name,
588                                            StringRef LinkageName,
589                                            DIFile File, unsigned LineNo,
590                                            DICompositeType Ty, bool isLocalToUnit,
591                                            bool isDefinition,
592                                            unsigned ScopeLine,
593                                            unsigned Flags = 0,
594                                            bool isOptimized = false,
595                                            Function *Fn = nullptr,
596                                            MDNode *TParam = nullptr,
597                                            MDNode *Decl = nullptr);
598
599
600     /// FIXME: this is added for dragonegg. Once we update dragonegg
601     /// to call resolve function, this will be removed.
602     DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
603                                 StringRef LinkageName,
604                                 DIFile File, unsigned LineNo,
605                                 DICompositeType Ty, bool isLocalToUnit,
606                                 bool isDefinition,
607                                 unsigned ScopeLine,
608                                 unsigned Flags = 0,
609                                 bool isOptimized = false,
610                                 Function *Fn = nullptr,
611                                 MDNode *TParam = nullptr,
612                                 MDNode *Decl = nullptr);
613
614     /// createMethod - Create a new descriptor for the specified C++ method.
615     /// See comments in DISubprogram for descriptions of these fields.
616     /// @param Scope         Function scope.
617     /// @param Name          Function name.
618     /// @param LinkageName   Mangled function name.
619     /// @param File          File where this variable is defined.
620     /// @param LineNo        Line number.
621     /// @param Ty            Function type.
622     /// @param isLocalToUnit True if this function is not externally visible..
623     /// @param isDefinition  True if this is a function definition.
624     /// @param Virtuality    Attributes describing virtualness. e.g. pure
625     ///                      virtual function.
626     /// @param VTableIndex   Index no of this method in virtual table.
627     /// @param VTableHolder  Type that holds vtable.
628     /// @param Flags         e.g. is this function prototyped or not.
629     ///                      This flags are used to emit dwarf attributes.
630     /// @param isOptimized   True if optimization is ON.
631     /// @param Fn            llvm::Function pointer.
632     /// @param TParam        Function template parameters.
633     DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
634                               StringRef LinkageName,
635                               DIFile File, unsigned LineNo,
636                               DICompositeType Ty, bool isLocalToUnit,
637                               bool isDefinition,
638                               unsigned Virtuality = 0, unsigned VTableIndex = 0,
639                               DIType VTableHolder = DIType(),
640                               unsigned Flags = 0,
641                               bool isOptimized = false,
642                               Function *Fn = nullptr,
643                               MDNode *TParam = nullptr);
644
645     /// createNameSpace - This creates new descriptor for a namespace
646     /// with the specified parent scope.
647     /// @param Scope       Namespace scope
648     /// @param Name        Name of this namespace
649     /// @param File        Source file
650     /// @param LineNo      Line number
651     DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name,
652                                 DIFile File, unsigned LineNo);
653
654
655     /// createLexicalBlockFile - This creates a descriptor for a lexical
656     /// block with a new file attached. This merely extends the existing
657     /// lexical block as it crosses a file.
658     /// @param Scope       Lexical block.
659     /// @param File        Source file.
660     /// @param Discriminator DWARF path discriminator value.
661     DILexicalBlockFile createLexicalBlockFile(DIDescriptor Scope, DIFile File,
662                                               unsigned Discriminator = 0);
663
664     /// createLexicalBlock - This creates a descriptor for a lexical block
665     /// with the specified parent context.
666     /// @param Scope         Parent lexical scope.
667     /// @param File          Source file.
668     /// @param Line          Line number.
669     /// @param Col           Column number.
670     DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
671                                       unsigned Line, unsigned Col);
672
673     /// \brief Create a descriptor for an imported module.
674     /// @param Context The scope this module is imported into
675     /// @param NS The namespace being imported here
676     /// @param Line Line number
677     DIImportedEntity createImportedModule(DIScope Context, DINameSpace NS,
678                                           unsigned Line);
679
680     /// \brief Create a descriptor for an imported module.
681     /// @param Context The scope this module is imported into
682     /// @param NS An aliased namespace
683     /// @param Line Line number
684     DIImportedEntity createImportedModule(DIScope Context, DIImportedEntity NS,
685                                           unsigned Line);
686
687     /// \brief Create a descriptor for an imported function.
688     /// @param Context The scope this module is imported into
689     /// @param Decl The declaration (or definition) of a function, type, or
690     ///             variable
691     /// @param Line Line number
692     DIImportedEntity createImportedDeclaration(DIScope Context, DIScope Decl,
693                                                unsigned Line,
694                                                StringRef Name = StringRef());
695     DIImportedEntity createImportedDeclaration(DIScope Context,
696                                                DIImportedEntity NS,
697                                                unsigned Line,
698                                                StringRef Name = StringRef());
699
700     /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
701     /// @param Storage     llvm::Value of the variable
702     /// @param VarInfo     Variable's debug info descriptor.
703     /// @param InsertAtEnd Location for the new intrinsic.
704     Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
705                                BasicBlock *InsertAtEnd);
706
707     /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
708     /// @param Storage      llvm::Value of the variable
709     /// @param VarInfo      Variable's debug info descriptor.
710     /// @param InsertBefore Location for the new intrinsic.
711     Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
712                                Instruction *InsertBefore);
713
714
715     /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
716     /// @param Val          llvm::Value of the variable
717     /// @param Offset       Offset
718     /// @param VarInfo      Variable's debug info descriptor.
719     /// @param InsertAtEnd Location for the new intrinsic.
720     Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
721                                          DIVariable VarInfo,
722                                          BasicBlock *InsertAtEnd);
723
724     /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
725     /// @param Val          llvm::Value of the variable
726     /// @param Offset       Offset
727     /// @param VarInfo      Variable's debug info descriptor.
728     /// @param InsertBefore Location for the new intrinsic.
729     Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
730                                          DIVariable VarInfo,
731                                          Instruction *InsertBefore);
732   };
733 } // end namespace llvm
734
735 #endif