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