[Debug Info] add a template class DITypedArray.
[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 };
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 PropertyName Name of the Objective C property associated with
236     ///                     this ivar.
237     /// @param PropertyGetterName Name of the Objective C property getter
238     ///                           selector.
239     /// @param PropertySetterName Name of the Objective C property setter
240     ///                           selector.
241     /// @param PropertyAttributes Objective C property attributes.
242     DIDerivedType createObjCIVar(StringRef Name, DIFile File,
243                                  unsigned LineNo, uint64_t SizeInBits,
244                                  uint64_t AlignInBits, uint64_t OffsetInBits,
245                                  unsigned Flags, DIType Ty,
246                                  StringRef PropertyName = StringRef(),
247                                  StringRef PropertyGetterName = StringRef(),
248                                  StringRef PropertySetterName = StringRef(),
249                                  unsigned PropertyAttributes = 0);
250
251     /// createObjCIVar - Create debugging information entry for Objective-C
252     /// instance variable.
253     /// @param Name         Member name.
254     /// @param File         File where this member is defined.
255     /// @param LineNo       Line number.
256     /// @param SizeInBits   Member size.
257     /// @param AlignInBits  Member alignment.
258     /// @param OffsetInBits Member offset.
259     /// @param Flags        Flags to encode member attribute, e.g. private
260     /// @param Ty           Parent type.
261     /// @param PropertyNode Property associated with this ivar.
262     DIDerivedType createObjCIVar(StringRef Name, DIFile File,
263                                  unsigned LineNo, uint64_t SizeInBits,
264                                  uint64_t AlignInBits, uint64_t OffsetInBits,
265                                  unsigned Flags, DIType Ty,
266                                  MDNode *PropertyNode);
267
268     /// createObjCProperty - Create debugging information entry for Objective-C
269     /// property.
270     /// @param Name         Property name.
271     /// @param File         File where this property is defined.
272     /// @param LineNumber   Line number.
273     /// @param GetterName   Name of the Objective C property getter selector.
274     /// @param SetterName   Name of the Objective C property setter selector.
275     /// @param PropertyAttributes Objective C property attributes.
276     /// @param Ty           Type.
277     DIObjCProperty createObjCProperty(StringRef Name,
278                                       DIFile File, unsigned LineNumber,
279                                       StringRef GetterName,
280                                       StringRef SetterName,
281                                       unsigned PropertyAttributes,
282                                       DIType Ty);
283
284     /// createClassType - Create debugging information entry for a class.
285     /// @param Scope        Scope in which this class is defined.
286     /// @param Name         class name.
287     /// @param File         File where this member is defined.
288     /// @param LineNumber   Line number.
289     /// @param SizeInBits   Member size.
290     /// @param AlignInBits  Member alignment.
291     /// @param OffsetInBits Member offset.
292     /// @param Flags        Flags to encode member attribute, e.g. private
293     /// @param Elements     class members.
294     /// @param VTableHolder Debug info of the base class that contains vtable
295     ///                     for this type. This is used in
296     ///                     DW_AT_containing_type. See DWARF documentation
297     ///                     for more info.
298     /// @param TemplateParms Template type parameters.
299     /// @param UniqueIdentifier A unique identifier for the class.
300     DICompositeType createClassType(DIDescriptor Scope, StringRef Name,
301                                     DIFile File, unsigned LineNumber,
302                                     uint64_t SizeInBits, uint64_t AlignInBits,
303                                     uint64_t OffsetInBits, unsigned Flags,
304                                     DIType DerivedFrom, DIArray Elements,
305                                     DIType VTableHolder = DIType(),
306                                     MDNode *TemplateParms = nullptr,
307                                     StringRef UniqueIdentifier = StringRef());
308
309     /// createStructType - Create debugging information entry for a struct.
310     /// @param Scope        Scope in which this struct is defined.
311     /// @param Name         Struct name.
312     /// @param File         File where this member is defined.
313     /// @param LineNumber   Line number.
314     /// @param SizeInBits   Member size.
315     /// @param AlignInBits  Member alignment.
316     /// @param Flags        Flags to encode member attribute, e.g. private
317     /// @param Elements     Struct elements.
318     /// @param RunTimeLang  Optional parameter, Objective-C runtime version.
319     /// @param UniqueIdentifier A unique identifier for the struct.
320     DICompositeType createStructType(DIDescriptor Scope, StringRef Name,
321                                      DIFile File, unsigned LineNumber,
322                                      uint64_t SizeInBits, uint64_t AlignInBits,
323                                      unsigned Flags, DIType DerivedFrom,
324                                      DIArray Elements, unsigned RunTimeLang = 0,
325                                      DIType VTableHolder = DIType(),
326                                      StringRef UniqueIdentifier = StringRef());
327
328     /// createUnionType - Create debugging information entry for an union.
329     /// @param Scope        Scope in which this union is defined.
330     /// @param Name         Union name.
331     /// @param File         File where this member is defined.
332     /// @param LineNumber   Line number.
333     /// @param SizeInBits   Member size.
334     /// @param AlignInBits  Member alignment.
335     /// @param Flags        Flags to encode member attribute, e.g. private
336     /// @param Elements     Union elements.
337     /// @param RunTimeLang  Optional parameter, Objective-C runtime version.
338     /// @param UniqueIdentifier A unique identifier for the union.
339     DICompositeType createUnionType(
340         DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
341         uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
342         DIArray Elements, unsigned RunTimeLang = 0,
343         StringRef UniqueIdentifier = StringRef());
344
345     /// createTemplateTypeParameter - Create debugging information for template
346     /// type parameter.
347     /// @param Scope        Scope in which this type is defined.
348     /// @param Name         Type parameter name.
349     /// @param Ty           Parameter type.
350     /// @param File         File where this type parameter is defined.
351     /// @param LineNo       Line number.
352     /// @param ColumnNo     Column Number.
353     DITemplateTypeParameter
354     createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
355                                 MDNode *File = nullptr, unsigned LineNo = 0,
356                                 unsigned ColumnNo = 0);
357
358     /// createTemplateValueParameter - Create debugging information for template
359     /// value parameter.
360     /// @param Scope        Scope in which this type is defined.
361     /// @param Name         Value parameter name.
362     /// @param Ty           Parameter type.
363     /// @param Val          Constant parameter value.
364     /// @param File         File where this type parameter is defined.
365     /// @param LineNo       Line number.
366     /// @param ColumnNo     Column Number.
367     DITemplateValueParameter
368     createTemplateValueParameter(DIDescriptor Scope, StringRef Name,
369                                  DIType Ty, Value *Val, MDNode *File = nullptr,
370                                  unsigned LineNo = 0, unsigned ColumnNo = 0);
371
372     /// \brief Create debugging information for a template template parameter.
373     /// @param Scope        Scope in which this type is defined.
374     /// @param Name         Value parameter name.
375     /// @param Ty           Parameter type.
376     /// @param Val          The fully qualified name of the template.
377     /// @param File         File where this type parameter is defined.
378     /// @param LineNo       Line number.
379     /// @param ColumnNo     Column Number.
380     DITemplateValueParameter
381     createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name,
382                                     DIType Ty, StringRef Val,
383                                     MDNode *File = nullptr, unsigned LineNo = 0,
384                                     unsigned ColumnNo = 0);
385
386     /// \brief Create debugging information for a template parameter pack.
387     /// @param Scope        Scope in which this type is defined.
388     /// @param Name         Value parameter name.
389     /// @param Ty           Parameter type.
390     /// @param Val          An array of types in the pack.
391     /// @param File         File where this type parameter is defined.
392     /// @param LineNo       Line number.
393     /// @param ColumnNo     Column Number.
394     DITemplateValueParameter
395     createTemplateParameterPack(DIDescriptor Scope, StringRef Name,
396                                 DIType Ty, DIArray Val, MDNode *File = nullptr,
397                                 unsigned LineNo = 0, unsigned ColumnNo = 0);
398
399     /// createArrayType - Create debugging information entry for an array.
400     /// @param Size         Array size.
401     /// @param AlignInBits  Alignment.
402     /// @param Ty           Element type.
403     /// @param Subscripts   Subscripts.
404     DICompositeType createArrayType(uint64_t Size, uint64_t AlignInBits,
405                                     DIType Ty, DIArray Subscripts);
406
407     /// createVectorType - Create debugging information entry for a vector type.
408     /// @param Size         Array size.
409     /// @param AlignInBits  Alignment.
410     /// @param Ty           Element type.
411     /// @param Subscripts   Subscripts.
412     DICompositeType createVectorType(uint64_t Size, uint64_t AlignInBits,
413                                      DIType Ty, DIArray Subscripts);
414
415     /// createEnumerationType - Create debugging information entry for an
416     /// enumeration.
417     /// @param Scope          Scope in which this enumeration is defined.
418     /// @param Name           Union name.
419     /// @param File           File where this member is defined.
420     /// @param LineNumber     Line number.
421     /// @param SizeInBits     Member size.
422     /// @param AlignInBits    Member alignment.
423     /// @param Elements       Enumeration elements.
424     /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
425     /// @param UniqueIdentifier A unique identifier for the enum.
426     DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name,
427         DIFile File, unsigned LineNumber, uint64_t SizeInBits,
428         uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType,
429         StringRef UniqueIdentifier = StringRef());
430
431     /// createSubroutineType - Create subroutine type.
432     /// @param File            File in which this subroutine is defined.
433     /// @param ParameterTypes  An array of subroutine parameter types. This
434     ///                        includes return type at 0th index.
435     /// @param Flags           E.g.: LValueReference.
436     ///                        These flags are used to emit dwarf attributes.
437     DICompositeType createSubroutineType(DIFile File, DIArray ParameterTypes,
438                                          unsigned Flags = 0);
439
440     /// createArtificialType - Create a new DIType with "artificial" flag set.
441     DIType createArtificialType(DIType Ty);
442
443     /// createObjectPointerType - Create a new DIType with the "object pointer"
444     /// flag set.
445     DIType createObjectPointerType(DIType Ty);
446
447     /// \brief Create a permanent forward-declared type.
448     DICompositeType createForwardDecl(unsigned Tag, StringRef Name,
449                                       DIDescriptor Scope, DIFile F,
450                                       unsigned Line, unsigned RuntimeLang = 0,
451                                       uint64_t SizeInBits = 0,
452                                       uint64_t AlignInBits = 0,
453                                       StringRef UniqueIdentifier = StringRef());
454
455     /// \brief Create a temporary forward-declared type.
456     DICompositeType createReplaceableForwardDecl(
457         unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F,
458         unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
459         uint64_t AlignInBits = 0, StringRef UniqueIdentifier = StringRef());
460
461     /// retainType - Retain DIType in a module even if it is not referenced
462     /// through debug info anchors.
463     void retainType(DIType T);
464
465     /// createUnspecifiedParameter - Create unspecified parameter type
466     /// for a subroutine type.
467     DITrivialType createUnspecifiedParameter();
468
469     /// getOrCreateArray - Get a DIArray, create one if required.
470     DIArray getOrCreateArray(ArrayRef<Value *> Elements);
471
472     /// getOrCreateTypeArray - Get a DITypeArray, create one if required.
473     DITypeArray getOrCreateTypeArray(ArrayRef<Value *> Elements);
474
475     /// getOrCreateSubrange - Create a descriptor for a value range.  This
476     /// implicitly uniques the values returned.
477     DISubrange getOrCreateSubrange(int64_t Lo, int64_t Count);
478
479     /// createGlobalVariable - Create a new descriptor for the specified global.
480     /// @param Name        Name of the variable.
481     /// @param File        File where this variable is defined.
482     /// @param LineNo      Line number.
483     /// @param Ty          Variable Type.
484     /// @param isLocalToUnit Boolean flag indicate whether this variable is
485     ///                      externally visible or not.
486     /// @param Val         llvm::Value of the variable.
487     DIGlobalVariable
488     createGlobalVariable(StringRef Name, DIFile File, unsigned LineNo,
489                          DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val);
490
491     /// \brief Create a new descriptor for the specified global.
492     /// @param Name        Name of the variable.
493     /// @param LinkageName Mangled variable name.
494     /// @param File        File where this variable is defined.
495     /// @param LineNo      Line number.
496     /// @param Ty          Variable Type.
497     /// @param isLocalToUnit Boolean flag indicate whether this variable is
498     ///                      externally visible or not.
499     /// @param Val         llvm::Value of the variable.
500     DIGlobalVariable
501     createGlobalVariable(StringRef Name, StringRef LinkageName, DIFile File,
502                          unsigned LineNo, DITypeRef Ty, bool isLocalToUnit,
503                          llvm::Value *Val);
504
505     /// createStaticVariable - Create a new descriptor for the specified
506     /// variable.
507     /// @param Context     Variable scope.
508     /// @param Name        Name of the variable.
509     /// @param LinkageName Mangled  name of the variable.
510     /// @param File        File where this variable is defined.
511     /// @param LineNo      Line number.
512     /// @param Ty          Variable Type.
513     /// @param isLocalToUnit Boolean flag indicate whether this variable is
514     ///                      externally visible or not.
515     /// @param Val         llvm::Value of the variable.
516     /// @param Decl        Reference to the corresponding declaration.
517     DIGlobalVariable
518     createStaticVariable(DIDescriptor Context, StringRef Name,
519                          StringRef LinkageName, DIFile File, unsigned LineNo,
520                          DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
521                          MDNode *Decl = nullptr);
522
523
524     /// createLocalVariable - Create a new descriptor for the specified
525     /// local variable.
526     /// @param Tag         Dwarf TAG. Usually DW_TAG_auto_variable or
527     ///                    DW_TAG_arg_variable.
528     /// @param Scope       Variable scope.
529     /// @param Name        Variable name.
530     /// @param File        File where this variable is defined.
531     /// @param LineNo      Line number.
532     /// @param Ty          Variable Type
533     /// @param AlwaysPreserve Boolean. Set to true if debug info for this
534     ///                       variable should be preserved in optimized build.
535     /// @param Flags       Flags, e.g. artificial variable.
536     /// @param ArgNo       If this variable is an argument then this argument's
537     ///                    number. 1 indicates 1st argument.
538     DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
539                                    StringRef Name,
540                                    DIFile File, unsigned LineNo,
541                                    DITypeRef Ty, bool AlwaysPreserve = false,
542                                    unsigned Flags = 0,
543                                    unsigned ArgNo = 0);
544
545
546     /// createComplexVariable - Create a new descriptor for the specified
547     /// variable which has a complex address expression for its address.
548     /// @param Tag         Dwarf TAG. Usually DW_TAG_auto_variable or
549     ///                    DW_TAG_arg_variable.
550     /// @param Scope       Variable scope.
551     /// @param Name        Variable name.
552     /// @param F           File where this variable is defined.
553     /// @param LineNo      Line number.
554     /// @param Ty          Variable Type
555     /// @param Addr        An array of complex address operations.
556     /// @param ArgNo       If this variable is an argument then this argument's
557     ///                    number. 1 indicates 1st argument.
558     DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
559                                      StringRef Name, DIFile F, unsigned LineNo,
560                                      DITypeRef Ty, ArrayRef<Value *> Addr,
561                                      unsigned ArgNo = 0);
562
563     /// createFunction - Create a new descriptor for the specified subprogram.
564     /// See comments in DISubprogram for descriptions of these fields.
565     /// @param Scope         Function scope.
566     /// @param Name          Function name.
567     /// @param LinkageName   Mangled function name.
568     /// @param File          File where this variable is defined.
569     /// @param LineNo        Line number.
570     /// @param Ty            Function type.
571     /// @param isLocalToUnit True if this function is not externally visible.
572     /// @param isDefinition  True if this is a function definition.
573     /// @param ScopeLine     Set to the beginning of the scope this starts
574     /// @param Flags         e.g. is this function prototyped or not.
575     ///                      These flags are used to emit dwarf attributes.
576     /// @param isOptimized   True if optimization is ON.
577     /// @param Fn            llvm::Function pointer.
578     /// @param TParam        Function template parameters.
579     DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
580                                 StringRef LinkageName,
581                                 DIFile File, unsigned LineNo,
582                                 DICompositeType Ty, bool isLocalToUnit,
583                                 bool isDefinition,
584                                 unsigned ScopeLine,
585                                 unsigned Flags = 0,
586                                 bool isOptimized = false,
587                                 Function *Fn = nullptr,
588                                 MDNode *TParam = nullptr,
589                                 MDNode *Decl = nullptr);
590
591     /// FIXME: this is added for dragonegg. Once we update dragonegg
592     /// to call resolve function, this will be removed.
593     DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
594                                 StringRef LinkageName,
595                                 DIFile File, unsigned LineNo,
596                                 DICompositeType Ty, bool isLocalToUnit,
597                                 bool isDefinition,
598                                 unsigned ScopeLine,
599                                 unsigned Flags = 0,
600                                 bool isOptimized = false,
601                                 Function *Fn = nullptr,
602                                 MDNode *TParam = nullptr,
603                                 MDNode *Decl = nullptr);
604
605     /// createMethod - Create a new descriptor for the specified C++ method.
606     /// See comments in DISubprogram for descriptions of these fields.
607     /// @param Scope         Function scope.
608     /// @param Name          Function name.
609     /// @param LinkageName   Mangled function name.
610     /// @param File          File where this variable is defined.
611     /// @param LineNo        Line number.
612     /// @param Ty            Function type.
613     /// @param isLocalToUnit True if this function is not externally visible..
614     /// @param isDefinition  True if this is a function definition.
615     /// @param Virtuality    Attributes describing virtualness. e.g. pure
616     ///                      virtual function.
617     /// @param VTableIndex   Index no of this method in virtual table.
618     /// @param VTableHolder  Type that holds vtable.
619     /// @param Flags         e.g. is this function prototyped or not.
620     ///                      This flags are used to emit dwarf attributes.
621     /// @param isOptimized   True if optimization is ON.
622     /// @param Fn            llvm::Function pointer.
623     /// @param TParam        Function template parameters.
624     DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
625                               StringRef LinkageName,
626                               DIFile File, unsigned LineNo,
627                               DICompositeType Ty, bool isLocalToUnit,
628                               bool isDefinition,
629                               unsigned Virtuality = 0, unsigned VTableIndex = 0,
630                               DIType VTableHolder = DIType(),
631                               unsigned Flags = 0,
632                               bool isOptimized = false,
633                               Function *Fn = nullptr,
634                               MDNode *TParam = nullptr);
635
636     /// createNameSpace - This creates new descriptor for a namespace
637     /// with the specified parent scope.
638     /// @param Scope       Namespace scope
639     /// @param Name        Name of this namespace
640     /// @param File        Source file
641     /// @param LineNo      Line number
642     DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name,
643                                 DIFile File, unsigned LineNo);
644
645
646     /// createLexicalBlockFile - This creates a descriptor for a lexical
647     /// block with a new file attached. This merely extends the existing
648     /// lexical block as it crosses a file.
649     /// @param Scope       Lexical block.
650     /// @param File        Source file.
651     DILexicalBlockFile createLexicalBlockFile(DIDescriptor Scope,
652                                               DIFile File);
653
654     /// createLexicalBlock - This creates a descriptor for a lexical block
655     /// with the specified parent context.
656     /// @param Scope         Parent lexical scope.
657     /// @param File          Source file.
658     /// @param Line          Line number.
659     /// @param Col           Column number.
660     /// @param Discriminator DWARF path discriminator value.
661     DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
662                                       unsigned Line, unsigned Col,
663                                       unsigned Discriminator);
664
665     /// \brief Create a descriptor for an imported module.
666     /// @param Context The scope this module is imported into
667     /// @param NS The namespace being imported here
668     /// @param Line Line number
669     DIImportedEntity createImportedModule(DIScope Context, DINameSpace NS,
670                                           unsigned Line);
671
672     /// \brief Create a descriptor for an imported module.
673     /// @param Context The scope this module is imported into
674     /// @param NS An aliased namespace
675     /// @param Line Line number
676     DIImportedEntity createImportedModule(DIScope Context, DIImportedEntity NS,
677                                           unsigned Line);
678
679     /// \brief Create a descriptor for an imported function.
680     /// @param Context The scope this module is imported into
681     /// @param Decl The declaration (or definition) of a function, type, or
682     ///             variable
683     /// @param Line Line number
684     DIImportedEntity createImportedDeclaration(DIScope Context, DIScope Decl,
685                                                unsigned Line,
686                                                StringRef Name = StringRef());
687     DIImportedEntity createImportedDeclaration(DIScope Context,
688                                                DIImportedEntity NS,
689                                                unsigned Line,
690                                                StringRef Name = StringRef());
691
692     /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
693     /// @param Storage     llvm::Value of the variable
694     /// @param VarInfo     Variable's debug info descriptor.
695     /// @param InsertAtEnd Location for the new intrinsic.
696     Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
697                                BasicBlock *InsertAtEnd);
698
699     /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
700     /// @param Storage      llvm::Value of the variable
701     /// @param VarInfo      Variable's debug info descriptor.
702     /// @param InsertBefore Location for the new intrinsic.
703     Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
704                                Instruction *InsertBefore);
705
706
707     /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
708     /// @param Val          llvm::Value of the variable
709     /// @param Offset       Offset
710     /// @param VarInfo      Variable's debug info descriptor.
711     /// @param InsertAtEnd Location for the new intrinsic.
712     Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
713                                          DIVariable VarInfo,
714                                          BasicBlock *InsertAtEnd);
715
716     /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
717     /// @param Val          llvm::Value of the variable
718     /// @param Offset       Offset
719     /// @param VarInfo      Variable's debug info descriptor.
720     /// @param InsertBefore Location for the new intrinsic.
721     Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
722                                          DIVariable VarInfo,
723                                          Instruction *InsertBefore);
724
725   };
726 } // end namespace llvm
727
728 #endif