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