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