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