LLVM API Documentation

DIBuilder.h
Go to the documentation of this file.
00001 //===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines a DIBuilder that is useful for creating debugging
00011 // information entries in LLVM IR form.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_IR_DIBUILDER_H
00016 #define LLVM_IR_DIBUILDER_H
00017 
00018 #include "llvm/ADT/ArrayRef.h"
00019 #include "llvm/ADT/StringRef.h"
00020 #include "llvm/IR/DebugInfo.h"
00021 #include "llvm/IR/ValueHandle.h"
00022 #include "llvm/Support/DataTypes.h"
00023 
00024 namespace llvm {
00025   class BasicBlock;
00026   class Instruction;
00027   class Function;
00028   class Module;
00029   class Value;
00030   class LLVMContext;
00031   class MDNode;
00032   class StringRef;
00033   class DIBasicType;
00034   class DICompileUnit;
00035   class DICompositeType;
00036   class DIDerivedType;
00037   class DIDescriptor;
00038   class DIFile;
00039   class DIEnumerator;
00040   class DIType;
00041   class DIGlobalVariable;
00042   class DIImportedEntity;
00043   class DINameSpace;
00044   class DIVariable;
00045   class DISubrange;
00046   class DILexicalBlockFile;
00047   class DILexicalBlock;
00048   class DIScope;
00049   class DISubprogram;
00050   class DITemplateTypeParameter;
00051   class DITemplateValueParameter;
00052   class DIObjCProperty;
00053 
00054   class DIBuilder {
00055     private:
00056     Module &M;
00057     LLVMContext &VMContext;
00058 
00059     MDNode *TempEnumTypes;
00060     MDNode *TempRetainTypes;
00061     MDNode *TempSubprograms;
00062     MDNode *TempGVs;
00063     MDNode *TempImportedModules;
00064 
00065     Function *DeclareFn;     // llvm.dbg.declare
00066     Function *ValueFn;       // llvm.dbg.value
00067 
00068     SmallVector<Value *, 4> AllEnumTypes;
00069     /// Use TrackingVH to collect RetainTypes, since they can be updated
00070     /// later on.
00071     SmallVector<TrackingVH<MDNode>, 4> AllRetainTypes;
00072     SmallVector<Value *, 4> AllSubprograms;
00073     SmallVector<Value *, 4> AllGVs;
00074     SmallVector<TrackingVH<MDNode>, 4> AllImportedModules;
00075 
00076     // Private use for multiple types of template parameters.
00077     DITemplateValueParameter
00078     createTemplateValueParameter(unsigned Tag, DIDescriptor Scope,
00079                                  StringRef Name, DIType Ty, Value *Val,
00080                                  MDNode *File = nullptr, unsigned LineNo = 0,
00081                                  unsigned ColumnNo = 0);
00082 
00083     DIBuilder(const DIBuilder &) LLVM_DELETED_FUNCTION;
00084     void operator=(const DIBuilder &) LLVM_DELETED_FUNCTION;
00085 
00086     public:
00087     explicit DIBuilder(Module &M);
00088     enum ComplexAddrKind { OpPlus=1, OpDeref, OpPiece };
00089     enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
00090 
00091     /// finalize - Construct any deferred debug info descriptors.
00092     void finalize();
00093 
00094     /// createCompileUnit - A CompileUnit provides an anchor for all debugging
00095     /// information generated during this instance of compilation.
00096     /// @param Lang     Source programming language, eg. dwarf::DW_LANG_C99
00097     /// @param File     File name
00098     /// @param Dir      Directory
00099     /// @param Producer Identify the producer of debugging information and code.
00100     ///                 Usually this is a compiler version string.
00101     /// @param isOptimized A boolean flag which indicates whether optimization
00102     ///                    is ON or not.
00103     /// @param Flags    This string lists command line options. This string is
00104     ///                 directly embedded in debug info output which may be used
00105     ///                 by a tool analyzing generated debugging information.
00106     /// @param RV       This indicates runtime version for languages like
00107     ///                 Objective-C.
00108     /// @param SplitName The name of the file that we'll split debug info out
00109     ///                  into.
00110     /// @param Kind     The kind of debug information to generate.
00111     /// @param EmitDebugInfo   A boolean flag which indicates whether debug
00112     ///                        information should be written to the final
00113     ///                        output or not. When this is false, debug
00114     ///                        information annotations will be present in
00115     ///                        the IL but they are not written to the final
00116     ///                        assembly or object file. This supports tracking
00117     ///                        source location information in the back end
00118     ///                        without actually changing the output (e.g.,
00119     ///                        when using optimization remarks).
00120     DICompileUnit createCompileUnit(unsigned Lang, StringRef File,
00121                                     StringRef Dir, StringRef Producer,
00122                                     bool isOptimized, StringRef Flags,
00123                                     unsigned RV,
00124                                     StringRef SplitName = StringRef(),
00125                                     DebugEmissionKind Kind = FullDebug,
00126                                     bool EmitDebugInfo = true);
00127 
00128     /// createFile - Create a file descriptor to hold debugging information
00129     /// for a file.
00130     DIFile createFile(StringRef Filename, StringRef Directory);
00131 
00132     /// createEnumerator - Create a single enumerator value.
00133     DIEnumerator createEnumerator(StringRef Name, int64_t Val);
00134 
00135     /// \brief Create a DWARF unspecified type.
00136     DIBasicType createUnspecifiedType(StringRef Name);
00137 
00138     /// \brief Create C++11 nullptr type.
00139     DIBasicType createNullPtrType();
00140 
00141     /// createBasicType - Create debugging information entry for a basic
00142     /// type.
00143     /// @param Name        Type name.
00144     /// @param SizeInBits  Size of the type.
00145     /// @param AlignInBits Type alignment.
00146     /// @param Encoding    DWARF encoding code, e.g. dwarf::DW_ATE_float.
00147     DIBasicType createBasicType(StringRef Name, uint64_t SizeInBits,
00148                                 uint64_t AlignInBits, unsigned Encoding);
00149 
00150     /// createQualifiedType - Create debugging information entry for a qualified
00151     /// type, e.g. 'const int'.
00152     /// @param Tag         Tag identifing type, e.g. dwarf::TAG_volatile_type
00153     /// @param FromTy      Base Type.
00154     DIDerivedType createQualifiedType(unsigned Tag, DIType FromTy);
00155 
00156     /// createPointerType - Create debugging information entry for a pointer.
00157     /// @param PointeeTy   Type pointed by this pointer.
00158     /// @param SizeInBits  Size.
00159     /// @param AlignInBits Alignment. (optional)
00160     /// @param Name        Pointer type name. (optional)
00161     DIDerivedType
00162     createPointerType(DIType PointeeTy, uint64_t SizeInBits,
00163                       uint64_t AlignInBits = 0, StringRef Name = StringRef());
00164 
00165     /// \brief Create debugging information entry for a pointer to member.
00166     /// @param PointeeTy Type pointed to by this pointer.
00167     /// @param Class Type for which this pointer points to members of.
00168     DIDerivedType createMemberPointerType(DIType PointeeTy, DIType Class);
00169 
00170     /// createReferenceType - Create debugging information entry for a c++
00171     /// style reference or rvalue reference type.
00172     DIDerivedType createReferenceType(unsigned Tag, DIType RTy);
00173 
00174     /// createTypedef - Create debugging information entry for a typedef.
00175     /// @param Ty          Original type.
00176     /// @param Name        Typedef name.
00177     /// @param File        File where this type is defined.
00178     /// @param LineNo      Line number.
00179     /// @param Context     The surrounding context for the typedef.
00180     DIDerivedType createTypedef(DIType Ty, StringRef Name, DIFile File,
00181                                 unsigned LineNo, DIDescriptor Context);
00182 
00183     /// createFriend - Create debugging information entry for a 'friend'.
00184     DIDerivedType createFriend(DIType Ty, DIType FriendTy);
00185 
00186     /// createInheritance - Create debugging information entry to establish
00187     /// inheritance relationship between two types.
00188     /// @param Ty           Original type.
00189     /// @param BaseTy       Base type. Ty is inherits from base.
00190     /// @param BaseOffset   Base offset.
00191     /// @param Flags        Flags to describe inheritance attribute,
00192     ///                     e.g. private
00193     DIDerivedType createInheritance(DIType Ty, DIType BaseTy,
00194                                     uint64_t BaseOffset, unsigned Flags);
00195 
00196     /// createMemberType - Create debugging information entry for a member.
00197     /// @param Scope        Member scope.
00198     /// @param Name         Member name.
00199     /// @param File         File where this member is defined.
00200     /// @param LineNo       Line number.
00201     /// @param SizeInBits   Member size.
00202     /// @param AlignInBits  Member alignment.
00203     /// @param OffsetInBits Member offset.
00204     /// @param Flags        Flags to encode member attribute, e.g. private
00205     /// @param Ty           Parent type.
00206     DIDerivedType
00207     createMemberType(DIDescriptor Scope, StringRef Name, DIFile File,
00208                      unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits,
00209                      uint64_t OffsetInBits, unsigned Flags, DIType Ty);
00210 
00211     /// createStaticMemberType - Create debugging information entry for a
00212     /// C++ static data member.
00213     /// @param Scope      Member scope.
00214     /// @param Name       Member name.
00215     /// @param File       File where this member is declared.
00216     /// @param LineNo     Line number.
00217     /// @param Ty         Type of the static member.
00218     /// @param Flags      Flags to encode member attribute, e.g. private.
00219     /// @param Val        Const initializer of the member.
00220     DIDerivedType
00221     createStaticMemberType(DIDescriptor Scope, StringRef Name,
00222                            DIFile File, unsigned LineNo, DIType Ty,
00223                            unsigned Flags, llvm::Value *Val);
00224 
00225     /// createObjCIVar - Create debugging information entry for Objective-C
00226     /// instance variable.
00227     /// @param Name         Member name.
00228     /// @param File         File where this member is defined.
00229     /// @param LineNo       Line number.
00230     /// @param SizeInBits   Member size.
00231     /// @param AlignInBits  Member alignment.
00232     /// @param OffsetInBits Member offset.
00233     /// @param Flags        Flags to encode member attribute, e.g. private
00234     /// @param Ty           Parent type.
00235     /// @param PropertyName Name of the Objective C property associated with
00236     ///                     this ivar.
00237     /// @param PropertyGetterName Name of the Objective C property getter
00238     ///                           selector.
00239     /// @param PropertySetterName Name of the Objective C property setter
00240     ///                           selector.
00241     /// @param PropertyAttributes Objective C property attributes.
00242     DIDerivedType createObjCIVar(StringRef Name, DIFile File,
00243                                  unsigned LineNo, uint64_t SizeInBits,
00244                                  uint64_t AlignInBits, uint64_t OffsetInBits,
00245                                  unsigned Flags, DIType Ty,
00246                                  StringRef PropertyName = StringRef(),
00247                                  StringRef PropertyGetterName = StringRef(),
00248                                  StringRef PropertySetterName = StringRef(),
00249                                  unsigned PropertyAttributes = 0);
00250 
00251     /// createObjCIVar - Create debugging information entry for Objective-C
00252     /// instance variable.
00253     /// @param Name         Member name.
00254     /// @param File         File where this member is defined.
00255     /// @param LineNo       Line number.
00256     /// @param SizeInBits   Member size.
00257     /// @param AlignInBits  Member alignment.
00258     /// @param OffsetInBits Member offset.
00259     /// @param Flags        Flags to encode member attribute, e.g. private
00260     /// @param Ty           Parent type.
00261     /// @param PropertyNode Property associated with this ivar.
00262     DIDerivedType createObjCIVar(StringRef Name, DIFile File,
00263                                  unsigned LineNo, uint64_t SizeInBits,
00264                                  uint64_t AlignInBits, uint64_t OffsetInBits,
00265                                  unsigned Flags, DIType Ty,
00266                                  MDNode *PropertyNode);
00267 
00268     /// createObjCProperty - Create debugging information entry for Objective-C
00269     /// property.
00270     /// @param Name         Property name.
00271     /// @param File         File where this property is defined.
00272     /// @param LineNumber   Line number.
00273     /// @param GetterName   Name of the Objective C property getter selector.
00274     /// @param SetterName   Name of the Objective C property setter selector.
00275     /// @param PropertyAttributes Objective C property attributes.
00276     /// @param Ty           Type.
00277     DIObjCProperty createObjCProperty(StringRef Name,
00278                                       DIFile File, unsigned LineNumber,
00279                                       StringRef GetterName,
00280                                       StringRef SetterName,
00281                                       unsigned PropertyAttributes,
00282                                       DIType Ty);
00283 
00284     /// createClassType - Create debugging information entry for a class.
00285     /// @param Scope        Scope in which this class is defined.
00286     /// @param Name         class name.
00287     /// @param File         File where this member is defined.
00288     /// @param LineNumber   Line number.
00289     /// @param SizeInBits   Member size.
00290     /// @param AlignInBits  Member alignment.
00291     /// @param OffsetInBits Member offset.
00292     /// @param Flags        Flags to encode member attribute, e.g. private
00293     /// @param Elements     class members.
00294     /// @param VTableHolder Debug info of the base class that contains vtable
00295     ///                     for this type. This is used in
00296     ///                     DW_AT_containing_type. See DWARF documentation
00297     ///                     for more info.
00298     /// @param TemplateParms Template type parameters.
00299     /// @param UniqueIdentifier A unique identifier for the class.
00300     DICompositeType createClassType(DIDescriptor Scope, StringRef Name,
00301                                     DIFile File, unsigned LineNumber,
00302                                     uint64_t SizeInBits, uint64_t AlignInBits,
00303                                     uint64_t OffsetInBits, unsigned Flags,
00304                                     DIType DerivedFrom, DIArray Elements,
00305                                     DIType VTableHolder = DIType(),
00306                                     MDNode *TemplateParms = nullptr,
00307                                     StringRef UniqueIdentifier = StringRef());
00308 
00309     /// createStructType - Create debugging information entry for a struct.
00310     /// @param Scope        Scope in which this struct is defined.
00311     /// @param Name         Struct name.
00312     /// @param File         File where this member is defined.
00313     /// @param LineNumber   Line number.
00314     /// @param SizeInBits   Member size.
00315     /// @param AlignInBits  Member alignment.
00316     /// @param Flags        Flags to encode member attribute, e.g. private
00317     /// @param Elements     Struct elements.
00318     /// @param RunTimeLang  Optional parameter, Objective-C runtime version.
00319     /// @param UniqueIdentifier A unique identifier for the struct.
00320     DICompositeType createStructType(DIDescriptor Scope, StringRef Name,
00321                                      DIFile File, unsigned LineNumber,
00322                                      uint64_t SizeInBits, uint64_t AlignInBits,
00323                                      unsigned Flags, DIType DerivedFrom,
00324                                      DIArray Elements, unsigned RunTimeLang = 0,
00325                                      DIType VTableHolder = DIType(),
00326                                      StringRef UniqueIdentifier = StringRef());
00327 
00328     /// createUnionType - Create debugging information entry for an union.
00329     /// @param Scope        Scope in which this union is defined.
00330     /// @param Name         Union name.
00331     /// @param File         File where this member is defined.
00332     /// @param LineNumber   Line number.
00333     /// @param SizeInBits   Member size.
00334     /// @param AlignInBits  Member alignment.
00335     /// @param Flags        Flags to encode member attribute, e.g. private
00336     /// @param Elements     Union elements.
00337     /// @param RunTimeLang  Optional parameter, Objective-C runtime version.
00338     /// @param UniqueIdentifier A unique identifier for the union.
00339     DICompositeType createUnionType(
00340         DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
00341         uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
00342         DIArray Elements, unsigned RunTimeLang = 0,
00343         StringRef UniqueIdentifier = StringRef());
00344 
00345     /// createTemplateTypeParameter - Create debugging information for template
00346     /// type parameter.
00347     /// @param Scope        Scope in which this type is defined.
00348     /// @param Name         Type parameter name.
00349     /// @param Ty           Parameter type.
00350     /// @param File         File where this type parameter is defined.
00351     /// @param LineNo       Line number.
00352     /// @param ColumnNo     Column Number.
00353     DITemplateTypeParameter
00354     createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
00355                                 MDNode *File = nullptr, unsigned LineNo = 0,
00356                                 unsigned ColumnNo = 0);
00357 
00358     /// createTemplateValueParameter - Create debugging information for template
00359     /// value parameter.
00360     /// @param Scope        Scope in which this type is defined.
00361     /// @param Name         Value parameter name.
00362     /// @param Ty           Parameter type.
00363     /// @param Val          Constant parameter value.
00364     /// @param File         File where this type parameter is defined.
00365     /// @param LineNo       Line number.
00366     /// @param ColumnNo     Column Number.
00367     DITemplateValueParameter
00368     createTemplateValueParameter(DIDescriptor Scope, StringRef Name,
00369                                  DIType Ty, Value *Val, MDNode *File = nullptr,
00370                                  unsigned LineNo = 0, unsigned ColumnNo = 0);
00371 
00372     /// \brief Create debugging information for a template template parameter.
00373     /// @param Scope        Scope in which this type is defined.
00374     /// @param Name         Value parameter name.
00375     /// @param Ty           Parameter type.
00376     /// @param Val          The fully qualified name of the template.
00377     /// @param File         File where this type parameter is defined.
00378     /// @param LineNo       Line number.
00379     /// @param ColumnNo     Column Number.
00380     DITemplateValueParameter
00381     createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name,
00382                                     DIType Ty, StringRef Val,
00383                                     MDNode *File = nullptr, unsigned LineNo = 0,
00384                                     unsigned ColumnNo = 0);
00385 
00386     /// \brief Create debugging information for a template parameter pack.
00387     /// @param Scope        Scope in which this type is defined.
00388     /// @param Name         Value parameter name.
00389     /// @param Ty           Parameter type.
00390     /// @param Val          An array of types in the pack.
00391     /// @param File         File where this type parameter is defined.
00392     /// @param LineNo       Line number.
00393     /// @param ColumnNo     Column Number.
00394     DITemplateValueParameter
00395     createTemplateParameterPack(DIDescriptor Scope, StringRef Name,
00396                                 DIType Ty, DIArray Val, MDNode *File = nullptr,
00397                                 unsigned LineNo = 0, unsigned ColumnNo = 0);
00398 
00399     /// createArrayType - Create debugging information entry for an array.
00400     /// @param Size         Array size.
00401     /// @param AlignInBits  Alignment.
00402     /// @param Ty           Element type.
00403     /// @param Subscripts   Subscripts.
00404     DICompositeType createArrayType(uint64_t Size, uint64_t AlignInBits,
00405                                     DIType Ty, DIArray Subscripts);
00406 
00407     /// createVectorType - Create debugging information entry for a vector type.
00408     /// @param Size         Array size.
00409     /// @param AlignInBits  Alignment.
00410     /// @param Ty           Element type.
00411     /// @param Subscripts   Subscripts.
00412     DICompositeType createVectorType(uint64_t Size, uint64_t AlignInBits,
00413                                      DIType Ty, DIArray Subscripts);
00414 
00415     /// createEnumerationType - Create debugging information entry for an
00416     /// enumeration.
00417     /// @param Scope          Scope in which this enumeration is defined.
00418     /// @param Name           Union name.
00419     /// @param File           File where this member is defined.
00420     /// @param LineNumber     Line number.
00421     /// @param SizeInBits     Member size.
00422     /// @param AlignInBits    Member alignment.
00423     /// @param Elements       Enumeration elements.
00424     /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
00425     /// @param UniqueIdentifier A unique identifier for the enum.
00426     DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name,
00427         DIFile File, unsigned LineNumber, uint64_t SizeInBits,
00428         uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType,
00429         StringRef UniqueIdentifier = StringRef());
00430 
00431     /// createSubroutineType - Create subroutine type.
00432     /// @param File            File in which this subroutine is defined.
00433     /// @param ParameterTypes  An array of subroutine parameter types. This
00434     ///                        includes return type at 0th index.
00435     /// @param Flags           E.g.: LValueReference.
00436     ///                        These flags are used to emit dwarf attributes.
00437     DISubroutineType createSubroutineType(DIFile File,
00438                                           DITypeArray ParameterTypes,
00439                                           unsigned Flags = 0);
00440 
00441     /// createArtificialType - Create a new DIType with "artificial" flag set.
00442     DIType createArtificialType(DIType Ty);
00443 
00444     /// createObjectPointerType - Create a new DIType with the "object pointer"
00445     /// flag set.
00446     DIType createObjectPointerType(DIType Ty);
00447 
00448     /// \brief Create a permanent forward-declared type.
00449     DICompositeType createForwardDecl(unsigned Tag, StringRef Name,
00450                                       DIDescriptor Scope, DIFile F,
00451                                       unsigned Line, unsigned RuntimeLang = 0,
00452                                       uint64_t SizeInBits = 0,
00453                                       uint64_t AlignInBits = 0,
00454                                       StringRef UniqueIdentifier = StringRef());
00455 
00456     /// \brief Create a temporary forward-declared type.
00457     DICompositeType createReplaceableForwardDecl(
00458         unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F,
00459         unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
00460         uint64_t AlignInBits = 0, StringRef UniqueIdentifier = StringRef());
00461 
00462     /// retainType - Retain DIType in a module even if it is not referenced
00463     /// through debug info anchors.
00464     void retainType(DIType T);
00465 
00466     /// createUnspecifiedParameter - Create unspecified parameter type
00467     /// for a subroutine type.
00468     DIBasicType createUnspecifiedParameter();
00469 
00470     /// getOrCreateArray - Get a DIArray, create one if required.
00471     DIArray getOrCreateArray(ArrayRef<Value *> Elements);
00472 
00473     /// getOrCreateTypeArray - Get a DITypeArray, create one if required.
00474     DITypeArray getOrCreateTypeArray(ArrayRef<Value *> Elements);
00475 
00476     /// getOrCreateSubrange - Create a descriptor for a value range.  This
00477     /// implicitly uniques the values returned.
00478     DISubrange getOrCreateSubrange(int64_t Lo, int64_t Count);
00479 
00480     /// createGlobalVariable - Create a new descriptor for the specified global.
00481     /// @param Name        Name of the variable.
00482     /// @param File        File where this variable is defined.
00483     /// @param LineNo      Line number.
00484     /// @param Ty          Variable Type.
00485     /// @param isLocalToUnit Boolean flag indicate whether this variable is
00486     ///                      externally visible or not.
00487     /// @param Val         llvm::Value of the variable.
00488     DIGlobalVariable
00489     createGlobalVariable(StringRef Name, DIFile File, unsigned LineNo,
00490                          DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val);
00491 
00492     /// \brief Create a new descriptor for the specified global.
00493     /// @param Name        Name of the variable.
00494     /// @param LinkageName Mangled variable name.
00495     /// @param File        File where this variable is defined.
00496     /// @param LineNo      Line number.
00497     /// @param Ty          Variable Type.
00498     /// @param isLocalToUnit Boolean flag indicate whether this variable is
00499     ///                      externally visible or not.
00500     /// @param Val         llvm::Value of the variable.
00501     DIGlobalVariable
00502     createGlobalVariable(StringRef Name, StringRef LinkageName, DIFile File,
00503                          unsigned LineNo, DITypeRef Ty, bool isLocalToUnit,
00504                          llvm::Value *Val);
00505 
00506     /// createStaticVariable - Create a new descriptor for the specified
00507     /// variable.
00508     /// @param Context     Variable scope.
00509     /// @param Name        Name of the variable.
00510     /// @param LinkageName Mangled  name of the variable.
00511     /// @param File        File where this variable is defined.
00512     /// @param LineNo      Line number.
00513     /// @param Ty          Variable Type.
00514     /// @param isLocalToUnit Boolean flag indicate whether this variable is
00515     ///                      externally visible or not.
00516     /// @param Val         llvm::Value of the variable.
00517     /// @param Decl        Reference to the corresponding declaration.
00518     DIGlobalVariable
00519     createStaticVariable(DIDescriptor Context, StringRef Name,
00520                          StringRef LinkageName, DIFile File, unsigned LineNo,
00521                          DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
00522                          MDNode *Decl = nullptr);
00523 
00524     /// createTempStaticVariableFwdDecl - Identical to createStaticVariable
00525     /// except that the resulting DbgNode is temporary and meant to be RAUWed.
00526     DIGlobalVariable
00527     createTempStaticVariableFwdDecl(DIDescriptor Context, StringRef Name,
00528                                     StringRef LinkageName, DIFile File,
00529                                     unsigned LineNo, DITypeRef Ty,
00530                                     bool isLocalToUnit, llvm::Value *Val,
00531                                     MDNode *Decl = nullptr);
00532 
00533 
00534     /// createLocalVariable - Create a new descriptor for the specified
00535     /// local variable.
00536     /// @param Tag         Dwarf TAG. Usually DW_TAG_auto_variable or
00537     ///                    DW_TAG_arg_variable.
00538     /// @param Scope       Variable scope.
00539     /// @param Name        Variable name.
00540     /// @param File        File where this variable is defined.
00541     /// @param LineNo      Line number.
00542     /// @param Ty          Variable Type
00543     /// @param AlwaysPreserve Boolean. Set to true if debug info for this
00544     ///                       variable should be preserved in optimized build.
00545     /// @param Flags       Flags, e.g. artificial variable.
00546     /// @param ArgNo       If this variable is an argument then this argument's
00547     ///                    number. 1 indicates 1st argument.
00548     DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
00549                                    StringRef Name,
00550                                    DIFile File, unsigned LineNo,
00551                                    DITypeRef Ty, bool AlwaysPreserve = false,
00552                                    unsigned Flags = 0,
00553                                    unsigned ArgNo = 0);
00554 
00555 
00556     /// createComplexVariable - Create a new descriptor for the specified
00557     /// variable which has a complex address expression for its address.
00558     /// @param Tag         Dwarf TAG. Usually DW_TAG_auto_variable or
00559     ///                    DW_TAG_arg_variable.
00560     /// @param Scope       Variable scope.
00561     /// @param Name        Variable name.
00562     /// @param F           File where this variable is defined.
00563     /// @param LineNo      Line number.
00564     /// @param Ty          Variable Type
00565     /// @param Addr        An array of complex address operations.
00566     /// @param ArgNo       If this variable is an argument then this argument's
00567     ///                    number. 1 indicates 1st argument.
00568     DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
00569                                      StringRef Name, DIFile F, unsigned LineNo,
00570                                      DITypeRef Ty, ArrayRef<Value *> Addr,
00571                                      unsigned ArgNo = 0);
00572 
00573     /// createVariablePiece - Create a descriptor to describe one part
00574     /// of aggregate variable that is fragmented across multiple Values.
00575     ///
00576     /// @param Variable      Variable that is partially represented by this.
00577     /// @param OffsetInBytes Offset of the piece in bytes.
00578     /// @param SizeInBytes   Size of the piece in bytes.
00579     DIVariable createVariablePiece(DIVariable Variable,
00580                                    unsigned OffsetInBytes,
00581                                    unsigned SizeInBytes);
00582 
00583     /// createFunction - Create a new descriptor for the specified subprogram.
00584     /// See comments in DISubprogram for descriptions of these fields.
00585     /// @param Scope         Function scope.
00586     /// @param Name          Function name.
00587     /// @param LinkageName   Mangled function name.
00588     /// @param File          File where this variable is defined.
00589     /// @param LineNo        Line number.
00590     /// @param Ty            Function type.
00591     /// @param isLocalToUnit True if this function is not externally visible.
00592     /// @param isDefinition  True if this is a function definition.
00593     /// @param ScopeLine     Set to the beginning of the scope this starts
00594     /// @param Flags         e.g. is this function prototyped or not.
00595     ///                      These flags are used to emit dwarf attributes.
00596     /// @param isOptimized   True if optimization is ON.
00597     /// @param Fn            llvm::Function pointer.
00598     /// @param TParam        Function template parameters.
00599     DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
00600                                 StringRef LinkageName,
00601                                 DIFile File, unsigned LineNo,
00602                                 DICompositeType Ty, bool isLocalToUnit,
00603                                 bool isDefinition,
00604                                 unsigned ScopeLine,
00605                                 unsigned Flags = 0,
00606                                 bool isOptimized = false,
00607                                 Function *Fn = nullptr,
00608                                 MDNode *TParam = nullptr,
00609                                 MDNode *Decl = nullptr);
00610 
00611     /// createTempFunctionFwdDecl - Identical to createFunction,
00612     /// except that the resulting DbgNode is meant to be RAUWed.
00613     DISubprogram createTempFunctionFwdDecl(DIDescriptor Scope, StringRef Name,
00614                                            StringRef LinkageName,
00615                                            DIFile File, unsigned LineNo,
00616                                            DICompositeType Ty, bool isLocalToUnit,
00617                                            bool isDefinition,
00618                                            unsigned ScopeLine,
00619                                            unsigned Flags = 0,
00620                                            bool isOptimized = false,
00621                                            Function *Fn = nullptr,
00622                                            MDNode *TParam = nullptr,
00623                                            MDNode *Decl = nullptr);
00624 
00625 
00626     /// FIXME: this is added for dragonegg. Once we update dragonegg
00627     /// to call resolve function, this will be removed.
00628     DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
00629                                 StringRef LinkageName,
00630                                 DIFile File, unsigned LineNo,
00631                                 DICompositeType Ty, bool isLocalToUnit,
00632                                 bool isDefinition,
00633                                 unsigned ScopeLine,
00634                                 unsigned Flags = 0,
00635                                 bool isOptimized = false,
00636                                 Function *Fn = nullptr,
00637                                 MDNode *TParam = nullptr,
00638                                 MDNode *Decl = nullptr);
00639 
00640     /// createMethod - Create a new descriptor for the specified C++ method.
00641     /// See comments in DISubprogram for descriptions of these fields.
00642     /// @param Scope         Function scope.
00643     /// @param Name          Function name.
00644     /// @param LinkageName   Mangled function name.
00645     /// @param File          File where this variable is defined.
00646     /// @param LineNo        Line number.
00647     /// @param Ty            Function type.
00648     /// @param isLocalToUnit True if this function is not externally visible..
00649     /// @param isDefinition  True if this is a function definition.
00650     /// @param Virtuality    Attributes describing virtualness. e.g. pure
00651     ///                      virtual function.
00652     /// @param VTableIndex   Index no of this method in virtual table.
00653     /// @param VTableHolder  Type that holds vtable.
00654     /// @param Flags         e.g. is this function prototyped or not.
00655     ///                      This flags are used to emit dwarf attributes.
00656     /// @param isOptimized   True if optimization is ON.
00657     /// @param Fn            llvm::Function pointer.
00658     /// @param TParam        Function template parameters.
00659     DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
00660                               StringRef LinkageName,
00661                               DIFile File, unsigned LineNo,
00662                               DICompositeType Ty, bool isLocalToUnit,
00663                               bool isDefinition,
00664                               unsigned Virtuality = 0, unsigned VTableIndex = 0,
00665                               DIType VTableHolder = DIType(),
00666                               unsigned Flags = 0,
00667                               bool isOptimized = false,
00668                               Function *Fn = nullptr,
00669                               MDNode *TParam = nullptr);
00670 
00671     /// createNameSpace - This creates new descriptor for a namespace
00672     /// with the specified parent scope.
00673     /// @param Scope       Namespace scope
00674     /// @param Name        Name of this namespace
00675     /// @param File        Source file
00676     /// @param LineNo      Line number
00677     DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name,
00678                                 DIFile File, unsigned LineNo);
00679 
00680 
00681     /// createLexicalBlockFile - This creates a descriptor for a lexical
00682     /// block with a new file attached. This merely extends the existing
00683     /// lexical block as it crosses a file.
00684     /// @param Scope       Lexical block.
00685     /// @param File        Source file.
00686     /// @param Discriminator DWARF path discriminator value.
00687     DILexicalBlockFile createLexicalBlockFile(DIDescriptor Scope, DIFile File,
00688                                               unsigned Discriminator = 0);
00689 
00690     /// createLexicalBlock - This creates a descriptor for a lexical block
00691     /// with the specified parent context.
00692     /// @param Scope         Parent lexical scope.
00693     /// @param File          Source file.
00694     /// @param Line          Line number.
00695     /// @param Col           Column number.
00696     DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
00697                                       unsigned Line, unsigned Col);
00698 
00699     /// \brief Create a descriptor for an imported module.
00700     /// @param Context The scope this module is imported into
00701     /// @param NS The namespace being imported here
00702     /// @param Line Line number
00703     DIImportedEntity createImportedModule(DIScope Context, DINameSpace NS,
00704                                           unsigned Line);
00705 
00706     /// \brief Create a descriptor for an imported module.
00707     /// @param Context The scope this module is imported into
00708     /// @param NS An aliased namespace
00709     /// @param Line Line number
00710     DIImportedEntity createImportedModule(DIScope Context, DIImportedEntity NS,
00711                                           unsigned Line);
00712 
00713     /// \brief Create a descriptor for an imported function.
00714     /// @param Context The scope this module is imported into
00715     /// @param Decl The declaration (or definition) of a function, type, or
00716     ///             variable
00717     /// @param Line Line number
00718     DIImportedEntity createImportedDeclaration(DIScope Context, DIScope Decl,
00719                                                unsigned Line,
00720                                                StringRef Name = StringRef());
00721     DIImportedEntity createImportedDeclaration(DIScope Context,
00722                                                DIImportedEntity NS,
00723                                                unsigned Line,
00724                                                StringRef Name = StringRef());
00725 
00726     /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
00727     /// @param Storage     llvm::Value of the variable
00728     /// @param VarInfo     Variable's debug info descriptor.
00729     /// @param InsertAtEnd Location for the new intrinsic.
00730     Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
00731                                BasicBlock *InsertAtEnd);
00732 
00733     /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
00734     /// @param Storage      llvm::Value of the variable
00735     /// @param VarInfo      Variable's debug info descriptor.
00736     /// @param InsertBefore Location for the new intrinsic.
00737     Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
00738                                Instruction *InsertBefore);
00739 
00740 
00741     /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
00742     /// @param Val          llvm::Value of the variable
00743     /// @param Offset       Offset
00744     /// @param VarInfo      Variable's debug info descriptor.
00745     /// @param InsertAtEnd Location for the new intrinsic.
00746     Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
00747                                          DIVariable VarInfo,
00748                                          BasicBlock *InsertAtEnd);
00749 
00750     /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
00751     /// @param Val          llvm::Value of the variable
00752     /// @param Offset       Offset
00753     /// @param VarInfo      Variable's debug info descriptor.
00754     /// @param InsertBefore Location for the new intrinsic.
00755     Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
00756                                          DIVariable VarInfo,
00757                                          Instruction *InsertBefore);
00758   };
00759 } // end namespace llvm
00760 
00761 #endif