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