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