LCOV - code coverage report
Current view: top level - include/llvm/IR - DIBuilder.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 7 7 100.0 %
Date: 2017-09-14 15:23:50 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file defines a DIBuilder that is useful for creating debugging
      11             : // information entries in LLVM IR form.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #ifndef LLVM_IR_DIBUILDER_H
      16             : #define LLVM_IR_DIBUILDER_H
      17             : 
      18             : #include "llvm/ADT/ArrayRef.h"
      19             : #include "llvm/ADT/DenseMap.h"
      20             : #include "llvm/ADT/MapVector.h"
      21             : #include "llvm/ADT/None.h"
      22             : #include "llvm/ADT/SetVector.h"
      23             : #include "llvm/ADT/SmallVector.h"
      24             : #include "llvm/ADT/StringRef.h"
      25             : #include "llvm/IR/DebugInfo.h"
      26             : #include "llvm/IR/DebugInfoMetadata.h"
      27             : #include "llvm/IR/TrackingMDRef.h"
      28             : #include "llvm/Support/Casting.h"
      29             : #include <algorithm>
      30             : #include <cstdint>
      31             : 
      32             : namespace llvm {
      33             : 
      34             :   class BasicBlock;
      35             :   class Constant;
      36             :   class Function;
      37             :   class Instruction;
      38             :   class LLVMContext;
      39             :   class Module;
      40             :   class Value;
      41             : 
      42     5473962 :   class DIBuilder {
      43             :     Module &M;
      44             :     LLVMContext &VMContext;
      45             : 
      46             :     DICompileUnit *CUNode;   ///< The one compile unit created by this DIBuiler.
      47             :     Function *DeclareFn;     ///< llvm.dbg.declare
      48             :     Function *ValueFn;       ///< llvm.dbg.value
      49             : 
      50             :     SmallVector<Metadata *, 4> AllEnumTypes;
      51             :     /// Track the RetainTypes, since they can be updated later on.
      52             :     SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
      53             :     SmallVector<Metadata *, 4> AllSubprograms;
      54             :     SmallVector<Metadata *, 4> AllGVs;
      55             :     SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
      56             :     /// Map Macro parent (which can be DIMacroFile or nullptr) to a list of
      57             :     /// Metadata all of type DIMacroNode.
      58             :     /// DIMacroNode's with nullptr parent are DICompileUnit direct children.
      59             :     MapVector<MDNode *, SetVector<Metadata *>> AllMacrosPerParent;
      60             : 
      61             :     /// Track nodes that may be unresolved.
      62             :     SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
      63             :     bool AllowUnresolvedNodes;
      64             : 
      65             :     /// Each subprogram's preserved local variables.
      66             :     ///
      67             :     /// Do not use a std::vector.  Some versions of libc++ apparently copy
      68             :     /// instead of move on grow operations, and TrackingMDRef is expensive to
      69             :     /// copy.
      70             :     DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables;
      71             : 
      72             :     /// Create a temporary.
      73             :     ///
      74             :     /// Create an \a temporary node and track it in \a UnresolvedNodes.
      75             :     void trackIfUnresolved(MDNode *N);
      76             : 
      77             :   public:
      78             :     /// Construct a builder for a module.
      79             :     ///
      80             :     /// If \c AllowUnresolved, collect unresolved nodes attached to the module
      81             :     /// in order to resolve cycles during \a finalize().
      82             :     explicit DIBuilder(Module &M, bool AllowUnresolved = true);
      83             :     DIBuilder(const DIBuilder &) = delete;
      84             :     DIBuilder &operator=(const DIBuilder &) = delete;
      85             : 
      86             :     /// Construct any deferred debug info descriptors.
      87             :     void finalize();
      88             : 
      89             :     /// Finalize a specific subprogram - no new variables may be added to this
      90             :     /// subprogram afterwards.
      91             :     void finalizeSubprogram(DISubprogram *SP);
      92             : 
      93             :     /// A CompileUnit provides an anchor for all debugging
      94             :     /// information generated during this instance of compilation.
      95             :     /// \param Lang          Source programming language, eg. dwarf::DW_LANG_C99
      96             :     /// \param File          File info.
      97             :     /// \param Producer      Identify the producer of debugging information
      98             :     ///                      and code.  Usually this is a compiler
      99             :     ///                      version string.
     100             :     /// \param isOptimized   A boolean flag which indicates whether optimization
     101             :     ///                      is enabled or not.
     102             :     /// \param Flags         This string lists command line options. This
     103             :     ///                      string is directly embedded in debug info
     104             :     ///                      output which may be used by a tool
     105             :     ///                      analyzing generated debugging information.
     106             :     /// \param RV            This indicates runtime version for languages like
     107             :     ///                      Objective-C.
     108             :     /// \param SplitName     The name of the file that we'll split debug info
     109             :     ///                      out into.
     110             :     /// \param Kind          The kind of debug information to generate.
     111             :     /// \param DWOId         The DWOId if this is a split skeleton compile unit.
     112             :     /// \param SplitDebugInlining    Whether to emit inline debug info.
     113             :     /// \param DebugInfoForProfiling Whether to emit extra debug info for
     114             :     ///                              profile collection.
     115             :     /// \param GnuPubnames   Whether to emit .debug_gnu_pubnames section instead
     116             :     ///                      of .debug_pubnames.
     117             :     DICompileUnit *
     118             :     createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer,
     119             :                       bool isOptimized, StringRef Flags, unsigned RV,
     120             :                       StringRef SplitName = StringRef(),
     121             :                       DICompileUnit::DebugEmissionKind Kind =
     122             :                           DICompileUnit::DebugEmissionKind::FullDebug,
     123             :                       uint64_t DWOId = 0, bool SplitDebugInlining = true,
     124             :                       bool DebugInfoForProfiling = false,
     125             :                       bool GnuPubnames = false);
     126             : 
     127             :     /// Create a file descriptor to hold debugging information for a file.
     128             :     /// \param Filename  File name.
     129             :     /// \param Directory Directory.
     130             :     /// \param CSKind    Checksum kind (e.g. CSK_None, CSK_MD5, CSK_SHA1, etc.).
     131             :     /// \param Checksum  Checksum data.
     132             :     DIFile *createFile(StringRef Filename, StringRef Directory,
     133             :                        DIFile::ChecksumKind CSKind = DIFile::CSK_None,
     134             :                        StringRef Checksum = StringRef());
     135             : 
     136             :     /// Create debugging information entry for a macro.
     137             :     /// \param Parent     Macro parent (could be nullptr).
     138             :     /// \param Line       Source line number where the macro is defined.
     139             :     /// \param MacroType  DW_MACINFO_define or DW_MACINFO_undef.
     140             :     /// \param Name       Macro name.
     141             :     /// \param Value      Macro value.
     142             :     DIMacro *createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType,
     143             :                          StringRef Name, StringRef Value = StringRef());
     144             : 
     145             :     /// Create debugging information temporary entry for a macro file.
     146             :     /// List of macro node direct children will be calculated by DIBuilder,
     147             :     /// using the \p Parent relationship.
     148             :     /// \param Parent     Macro file parent (could be nullptr).
     149             :     /// \param Line       Source line number where the macro file is included.
     150             :     /// \param File       File descriptor containing the name of the macro file.
     151             :     DIMacroFile *createTempMacroFile(DIMacroFile *Parent, unsigned Line,
     152             :                                      DIFile *File);
     153             : 
     154             :     /// Create a single enumerator value.
     155             :     DIEnumerator *createEnumerator(StringRef Name, int64_t Val);
     156             : 
     157             :     /// Create a DWARF unspecified type.
     158             :     DIBasicType *createUnspecifiedType(StringRef Name);
     159             : 
     160             :     /// Create C++11 nullptr type.
     161             :     DIBasicType *createNullPtrType();
     162             : 
     163             :     /// Create debugging information entry for a basic
     164             :     /// type.
     165             :     /// \param Name        Type name.
     166             :     /// \param SizeInBits  Size of the type.
     167             :     /// \param Encoding    DWARF encoding code, e.g. dwarf::DW_ATE_float.
     168             :     DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
     169             :                                  unsigned Encoding);
     170             : 
     171             :     /// Create debugging information entry for a qualified
     172             :     /// type, e.g. 'const int'.
     173             :     /// \param Tag         Tag identifing type, e.g. dwarf::TAG_volatile_type
     174             :     /// \param FromTy      Base Type.
     175             :     DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
     176             : 
     177             :     /// Create debugging information entry for a pointer.
     178             :     /// \param PointeeTy         Type pointed by this pointer.
     179             :     /// \param SizeInBits        Size.
     180             :     /// \param AlignInBits       Alignment. (optional)
     181             :     /// \param DWARFAddressSpace DWARF address space. (optional)
     182             :     /// \param Name              Pointer type name. (optional)
     183             :     DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
     184             :                                      uint32_t AlignInBits = 0,
     185             :                                      Optional<unsigned> DWARFAddressSpace =
     186             :                                          None,
     187             :                                      StringRef Name = "");
     188             : 
     189             :     /// Create debugging information entry for a pointer to member.
     190             :     /// \param PointeeTy Type pointed to by this pointer.
     191             :     /// \param SizeInBits  Size.
     192             :     /// \param AlignInBits Alignment. (optional)
     193             :     /// \param Class Type for which this pointer points to members of.
     194             :     DIDerivedType *
     195             :     createMemberPointerType(DIType *PointeeTy, DIType *Class,
     196             :                             uint64_t SizeInBits, uint32_t AlignInBits = 0,
     197             :                             DINode::DIFlags Flags = DINode::FlagZero);
     198             : 
     199             :     /// Create debugging information entry for a c++
     200             :     /// style reference or rvalue reference type.
     201             :     DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy,
     202             :                                        uint64_t SizeInBits = 0,
     203             :                                        uint32_t AlignInBits = 0,
     204             :                                        Optional<unsigned> DWARFAddressSpace =
     205             :                                            None);
     206             : 
     207             :     /// Create debugging information entry for a typedef.
     208             :     /// \param Ty          Original type.
     209             :     /// \param Name        Typedef name.
     210             :     /// \param File        File where this type is defined.
     211             :     /// \param LineNo      Line number.
     212             :     /// \param Context     The surrounding context for the typedef.
     213             :     DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
     214             :                                  unsigned LineNo, DIScope *Context);
     215             : 
     216             :     /// Create debugging information entry for a 'friend'.
     217             :     DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
     218             : 
     219             :     /// Create debugging information entry to establish
     220             :     /// inheritance relationship between two types.
     221             :     /// \param Ty           Original type.
     222             :     /// \param BaseTy       Base type. Ty is inherits from base.
     223             :     /// \param BaseOffset   Base offset.
     224             :     /// \param Flags        Flags to describe inheritance attribute,
     225             :     ///                     e.g. private
     226             :     DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
     227             :                                      uint64_t BaseOffset,
     228             :                                      DINode::DIFlags Flags);
     229             : 
     230             :     /// Create debugging information entry for a member.
     231             :     /// \param Scope        Member scope.
     232             :     /// \param Name         Member name.
     233             :     /// \param File         File where this member is defined.
     234             :     /// \param LineNo       Line number.
     235             :     /// \param SizeInBits   Member size.
     236             :     /// \param AlignInBits  Member alignment.
     237             :     /// \param OffsetInBits Member offset.
     238             :     /// \param Flags        Flags to encode member attribute, e.g. private
     239             :     /// \param Ty           Parent type.
     240             :     DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
     241             :                                     DIFile *File, unsigned LineNo,
     242             :                                     uint64_t SizeInBits,
     243             :                                     uint32_t AlignInBits,
     244             :                                     uint64_t OffsetInBits,
     245             :                                     DINode::DIFlags Flags, DIType *Ty);
     246             : 
     247             :     /// Create debugging information entry for a bit field member.
     248             :     /// \param Scope               Member scope.
     249             :     /// \param Name                Member name.
     250             :     /// \param File                File where this member is defined.
     251             :     /// \param LineNo              Line number.
     252             :     /// \param SizeInBits          Member size.
     253             :     /// \param OffsetInBits        Member offset.
     254             :     /// \param StorageOffsetInBits Member storage offset.
     255             :     /// \param Flags               Flags to encode member attribute.
     256             :     /// \param Ty                  Parent type.
     257             :     DIDerivedType *createBitFieldMemberType(
     258             :         DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
     259             :         uint64_t SizeInBits, uint64_t OffsetInBits,
     260             :         uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty);
     261             : 
     262             :     /// Create debugging information entry for a
     263             :     /// C++ static data member.
     264             :     /// \param Scope      Member scope.
     265             :     /// \param Name       Member name.
     266             :     /// \param File       File where this member is declared.
     267             :     /// \param LineNo     Line number.
     268             :     /// \param Ty         Type of the static member.
     269             :     /// \param Flags      Flags to encode member attribute, e.g. private.
     270             :     /// \param Val        Const initializer of the member.
     271             :     /// \param AlignInBits  Member alignment.
     272             :     DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
     273             :                                           DIFile *File, unsigned LineNo,
     274             :                                           DIType *Ty, DINode::DIFlags Flags,
     275             :                                           Constant *Val,
     276             :                                           uint32_t AlignInBits = 0);
     277             : 
     278             :     /// Create debugging information entry for Objective-C
     279             :     /// instance variable.
     280             :     /// \param Name         Member name.
     281             :     /// \param File         File where this member is defined.
     282             :     /// \param LineNo       Line number.
     283             :     /// \param SizeInBits   Member size.
     284             :     /// \param AlignInBits  Member alignment.
     285             :     /// \param OffsetInBits Member offset.
     286             :     /// \param Flags        Flags to encode member attribute, e.g. private
     287             :     /// \param Ty           Parent type.
     288             :     /// \param PropertyNode Property associated with this ivar.
     289             :     DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
     290             :                                   uint64_t SizeInBits, uint32_t AlignInBits,
     291             :                                   uint64_t OffsetInBits, DINode::DIFlags Flags,
     292             :                                   DIType *Ty, MDNode *PropertyNode);
     293             : 
     294             :     /// Create debugging information entry for Objective-C
     295             :     /// property.
     296             :     /// \param Name         Property name.
     297             :     /// \param File         File where this property is defined.
     298             :     /// \param LineNumber   Line number.
     299             :     /// \param GetterName   Name of the Objective C property getter selector.
     300             :     /// \param SetterName   Name of the Objective C property setter selector.
     301             :     /// \param PropertyAttributes Objective C property attributes.
     302             :     /// \param Ty           Type.
     303             :     DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
     304             :                                        unsigned LineNumber,
     305             :                                        StringRef GetterName,
     306             :                                        StringRef SetterName,
     307             :                                        unsigned PropertyAttributes, DIType *Ty);
     308             : 
     309             :     /// Create debugging information entry for a class.
     310             :     /// \param Scope        Scope in which this class is defined.
     311             :     /// \param Name         class name.
     312             :     /// \param File         File where this member is defined.
     313             :     /// \param LineNumber   Line number.
     314             :     /// \param SizeInBits   Member size.
     315             :     /// \param AlignInBits  Member alignment.
     316             :     /// \param OffsetInBits Member offset.
     317             :     /// \param Flags        Flags to encode member attribute, e.g. private
     318             :     /// \param Elements     class members.
     319             :     /// \param VTableHolder Debug info of the base class that contains vtable
     320             :     ///                     for this type. This is used in
     321             :     ///                     DW_AT_containing_type. See DWARF documentation
     322             :     ///                     for more info.
     323             :     /// \param TemplateParms Template type parameters.
     324             :     /// \param UniqueIdentifier A unique identifier for the class.
     325             :     DICompositeType *createClassType(
     326             :         DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
     327             :         uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
     328             :         DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
     329             :         DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
     330             :         StringRef UniqueIdentifier = "");
     331             : 
     332             :     /// Create debugging information entry for a struct.
     333             :     /// \param Scope        Scope in which this struct is defined.
     334             :     /// \param Name         Struct name.
     335             :     /// \param File         File where this member is defined.
     336             :     /// \param LineNumber   Line number.
     337             :     /// \param SizeInBits   Member size.
     338             :     /// \param AlignInBits  Member alignment.
     339             :     /// \param Flags        Flags to encode member attribute, e.g. private
     340             :     /// \param Elements     Struct elements.
     341             :     /// \param RunTimeLang  Optional parameter, Objective-C runtime version.
     342             :     /// \param UniqueIdentifier A unique identifier for the struct.
     343             :     DICompositeType *createStructType(
     344             :         DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
     345             :         uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
     346             :         DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
     347             :         DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
     348             : 
     349             :     /// Create debugging information entry for an union.
     350             :     /// \param Scope        Scope in which this union is defined.
     351             :     /// \param Name         Union name.
     352             :     /// \param File         File where this member is defined.
     353             :     /// \param LineNumber   Line number.
     354             :     /// \param SizeInBits   Member size.
     355             :     /// \param AlignInBits  Member alignment.
     356             :     /// \param Flags        Flags to encode member attribute, e.g. private
     357             :     /// \param Elements     Union elements.
     358             :     /// \param RunTimeLang  Optional parameter, Objective-C runtime version.
     359             :     /// \param UniqueIdentifier A unique identifier for the union.
     360             :     DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
     361             :                                      DIFile *File, unsigned LineNumber,
     362             :                                      uint64_t SizeInBits, uint32_t AlignInBits,
     363             :                                      DINode::DIFlags Flags,
     364             :                                      DINodeArray Elements,
     365             :                                      unsigned RunTimeLang = 0,
     366             :                                      StringRef UniqueIdentifier = "");
     367             : 
     368             :     /// Create debugging information for template
     369             :     /// type parameter.
     370             :     /// \param Scope        Scope in which this type is defined.
     371             :     /// \param Name         Type parameter name.
     372             :     /// \param Ty           Parameter type.
     373             :     DITemplateTypeParameter *
     374             :     createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty);
     375             : 
     376             :     /// Create debugging information for template
     377             :     /// value parameter.
     378             :     /// \param Scope        Scope in which this type is defined.
     379             :     /// \param Name         Value parameter name.
     380             :     /// \param Ty           Parameter type.
     381             :     /// \param Val          Constant parameter value.
     382             :     DITemplateValueParameter *createTemplateValueParameter(DIScope *Scope,
     383             :                                                            StringRef Name,
     384             :                                                            DIType *Ty,
     385             :                                                            Constant *Val);
     386             : 
     387             :     /// Create debugging information for a template template parameter.
     388             :     /// \param Scope        Scope in which this type is defined.
     389             :     /// \param Name         Value parameter name.
     390             :     /// \param Ty           Parameter type.
     391             :     /// \param Val          The fully qualified name of the template.
     392             :     DITemplateValueParameter *createTemplateTemplateParameter(DIScope *Scope,
     393             :                                                               StringRef Name,
     394             :                                                               DIType *Ty,
     395             :                                                               StringRef Val);
     396             : 
     397             :     /// Create debugging information for a template parameter pack.
     398             :     /// \param Scope        Scope in which this type is defined.
     399             :     /// \param Name         Value parameter name.
     400             :     /// \param Ty           Parameter type.
     401             :     /// \param Val          An array of types in the pack.
     402             :     DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
     403             :                                                           StringRef Name,
     404             :                                                           DIType *Ty,
     405             :                                                           DINodeArray Val);
     406             : 
     407             :     /// Create debugging information entry for an array.
     408             :     /// \param Size         Array size.
     409             :     /// \param AlignInBits  Alignment.
     410             :     /// \param Ty           Element type.
     411             :     /// \param Subscripts   Subscripts.
     412             :     DICompositeType *createArrayType(uint64_t Size, uint32_t AlignInBits,
     413             :                                      DIType *Ty, DINodeArray Subscripts);
     414             : 
     415             :     /// Create debugging information entry for a vector type.
     416             :     /// \param Size         Array size.
     417             :     /// \param AlignInBits  Alignment.
     418             :     /// \param Ty           Element type.
     419             :     /// \param Subscripts   Subscripts.
     420             :     DICompositeType *createVectorType(uint64_t Size, uint32_t AlignInBits,
     421             :                                       DIType *Ty, DINodeArray Subscripts);
     422             : 
     423             :     /// Create debugging information entry for an
     424             :     /// enumeration.
     425             :     /// \param Scope          Scope in which this enumeration is defined.
     426             :     /// \param Name           Union name.
     427             :     /// \param File           File where this member is defined.
     428             :     /// \param LineNumber     Line number.
     429             :     /// \param SizeInBits     Member size.
     430             :     /// \param AlignInBits    Member alignment.
     431             :     /// \param Elements       Enumeration elements.
     432             :     /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
     433             :     /// \param UniqueIdentifier A unique identifier for the enum.
     434             :     DICompositeType *createEnumerationType(
     435             :         DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
     436             :         uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
     437             :         DIType *UnderlyingType, StringRef UniqueIdentifier = "");
     438             : 
     439             :     /// Create subroutine type.
     440             :     /// \param ParameterTypes  An array of subroutine parameter types. This
     441             :     ///                        includes return type at 0th index.
     442             :     /// \param Flags           E.g.: LValueReference.
     443             :     ///                        These flags are used to emit dwarf attributes.
     444             :     /// \param CC              Calling convention, e.g. dwarf::DW_CC_normal
     445             :     DISubroutineType *
     446             :     createSubroutineType(DITypeRefArray ParameterTypes,
     447             :                          DINode::DIFlags Flags = DINode::FlagZero,
     448             :                          unsigned CC = 0);
     449             : 
     450             :     /// Create a new DIType* with "artificial" flag set.
     451             :     DIType *createArtificialType(DIType *Ty);
     452             : 
     453             :     /// Create a new DIType* with the "object pointer"
     454             :     /// flag set.
     455             :     DIType *createObjectPointerType(DIType *Ty);
     456             : 
     457             :     /// Create a permanent forward-declared type.
     458             :     DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
     459             :                                        DIScope *Scope, DIFile *F, unsigned Line,
     460             :                                        unsigned RuntimeLang = 0,
     461             :                                        uint64_t SizeInBits = 0,
     462             :                                        uint32_t AlignInBits = 0,
     463             :                                        StringRef UniqueIdentifier = "");
     464             : 
     465             :     /// Create a temporary forward-declared type.
     466             :     DICompositeType *createReplaceableCompositeType(
     467             :         unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
     468             :         unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
     469             :         uint32_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagFwdDecl,
     470             :         StringRef UniqueIdentifier = "");
     471             : 
     472             :     /// Retain DIScope* in a module even if it is not referenced
     473             :     /// through debug info anchors.
     474             :     void retainType(DIScope *T);
     475             : 
     476             :     /// Create unspecified parameter type
     477             :     /// for a subroutine type.
     478             :     DIBasicType *createUnspecifiedParameter();
     479             : 
     480             :     /// Get a DINodeArray, create one if required.
     481             :     DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
     482             : 
     483             :     /// Get a DIMacroNodeArray, create one if required.
     484             :     DIMacroNodeArray getOrCreateMacroArray(ArrayRef<Metadata *> Elements);
     485             : 
     486             :     /// Get a DITypeRefArray, create one if required.
     487             :     DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
     488             : 
     489             :     /// Create a descriptor for a value range.  This
     490             :     /// implicitly uniques the values returned.
     491             :     DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
     492             : 
     493             :     /// Create a new descriptor for the specified variable.
     494             :     /// \param Context     Variable scope.
     495             :     /// \param Name        Name of the variable.
     496             :     /// \param LinkageName Mangled  name of the variable.
     497             :     /// \param File        File where this variable is defined.
     498             :     /// \param LineNo      Line number.
     499             :     /// \param Ty          Variable Type.
     500             :     /// \param isLocalToUnit Boolean flag indicate whether this variable is
     501             :     ///                      externally visible or not.
     502             :     /// \param Expr        The location of the global relative to the attached
     503             :     ///                    GlobalVariable.
     504             :     /// \param Decl        Reference to the corresponding declaration.
     505             :     /// \param AlignInBits Variable alignment(or 0 if no alignment attr was
     506             :     ///                    specified)
     507             :     DIGlobalVariableExpression *createGlobalVariableExpression(
     508             :         DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
     509             :         unsigned LineNo, DIType *Ty, bool isLocalToUnit,
     510             :         DIExpression *Expr = nullptr, MDNode *Decl = nullptr,
     511             :         uint32_t AlignInBits = 0);
     512             : 
     513             :     /// Identical to createGlobalVariable
     514             :     /// except that the resulting DbgNode is temporary and meant to be RAUWed.
     515             :     DIGlobalVariable *createTempGlobalVariableFwdDecl(
     516             :         DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
     517             :         unsigned LineNo, DIType *Ty, bool isLocalToUnit, MDNode *Decl = nullptr,
     518             :         uint32_t AlignInBits = 0);
     519             : 
     520             :     /// Create a new descriptor for an auto variable.  This is a local variable
     521             :     /// that is not a subprogram parameter.
     522             :     ///
     523             :     /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
     524             :     /// leads to a \a DISubprogram.
     525             :     ///
     526             :     /// If \c AlwaysPreserve, this variable will be referenced from its
     527             :     /// containing subprogram, and will survive some optimizations.
     528             :     DILocalVariable *
     529             :     createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File,
     530             :                        unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false,
     531             :                        DINode::DIFlags Flags = DINode::FlagZero,
     532             :                        uint32_t AlignInBits = 0);
     533             : 
     534             :     /// Create a new descriptor for a parameter variable.
     535             :     ///
     536             :     /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
     537             :     /// leads to a \a DISubprogram.
     538             :     ///
     539             :     /// \c ArgNo is the index (starting from \c 1) of this variable in the
     540             :     /// subprogram parameters.  \c ArgNo should not conflict with other
     541             :     /// parameters of the same subprogram.
     542             :     ///
     543             :     /// If \c AlwaysPreserve, this variable will be referenced from its
     544             :     /// containing subprogram, and will survive some optimizations.
     545             :     DILocalVariable *
     546             :     createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo,
     547             :                             DIFile *File, unsigned LineNo, DIType *Ty,
     548             :                             bool AlwaysPreserve = false,
     549             :                             DINode::DIFlags Flags = DINode::FlagZero);
     550             : 
     551             :     /// Create a new descriptor for the specified
     552             :     /// variable which has a complex address expression for its address.
     553             :     /// \param Addr        An array of complex address operations.
     554             :     DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
     555             :     DIExpression *createExpression(ArrayRef<int64_t> Addr);
     556             : 
     557             :     /// Create an expression for a variable that does not have an address, but
     558             :     /// does have a constant value.
     559             :     DIExpression *createConstantValueExpression(uint64_t Val) {
     560          51 :       return DIExpression::get(
     561          17 :           VMContext, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_stack_value});
     562             :     }
     563             : 
     564             :     /// Create a new descriptor for the specified subprogram.
     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 ScopeLine     Set to the beginning of the scope this starts
     575             :     /// \param Flags         e.g. is this function prototyped or not.
     576             :     ///                      These flags are used to emit dwarf attributes.
     577             :     /// \param isOptimized   True if optimization is ON.
     578             :     /// \param TParams       Function template parameters.
     579             :     /// \param ThrownTypes   Exception types this function may throw.
     580             :     DISubprogram *createFunction(
     581             :         DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
     582             :         unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
     583             :         bool isDefinition, unsigned ScopeLine,
     584             :         DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
     585             :         DITemplateParameterArray TParams = nullptr,
     586             :         DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
     587             : 
     588             :     /// Identical to createFunction,
     589             :     /// except that the resulting DbgNode is meant to be RAUWed.
     590             :     DISubprogram *createTempFunctionFwdDecl(
     591             :         DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
     592             :         unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
     593             :         bool isDefinition, unsigned ScopeLine,
     594             :         DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
     595             :         DITemplateParameterArray TParams = nullptr,
     596             :         DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
     597             : 
     598             :     /// Create a new descriptor for the specified C++ method.
     599             :     /// See comments in \a DISubprogram* for descriptions of these fields.
     600             :     /// \param Scope         Function scope.
     601             :     /// \param Name          Function name.
     602             :     /// \param LinkageName   Mangled function name.
     603             :     /// \param File          File where this variable is defined.
     604             :     /// \param LineNo        Line number.
     605             :     /// \param Ty            Function type.
     606             :     /// \param isLocalToUnit True if this function is not externally visible..
     607             :     /// \param isDefinition  True if this is a function definition.
     608             :     /// \param Virtuality    Attributes describing virtualness. e.g. pure
     609             :     ///                      virtual function.
     610             :     /// \param VTableIndex   Index no of this method in virtual table, or -1u if
     611             :     ///                      unrepresentable.
     612             :     /// \param ThisAdjustment
     613             :     ///                      MS ABI-specific adjustment of 'this' that occurs
     614             :     ///                      in the prologue.
     615             :     /// \param VTableHolder  Type that holds vtable.
     616             :     /// \param Flags         e.g. is this function prototyped or not.
     617             :     ///                      This flags are used to emit dwarf attributes.
     618             :     /// \param isOptimized   True if optimization is ON.
     619             :     /// \param TParams       Function template parameters.
     620             :     /// \param ThrownTypes   Exception types this function may throw.
     621             :     DISubprogram *createMethod(
     622             :         DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
     623             :         unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
     624             :         bool isDefinition, unsigned Virtuality = 0, unsigned VTableIndex = 0,
     625             :         int ThisAdjustment = 0, DIType *VTableHolder = nullptr,
     626             :         DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
     627             :         DITemplateParameterArray TParams = nullptr,
     628             :         DITypeArray ThrownTypes = nullptr);
     629             : 
     630             :     /// This creates new descriptor for a namespace with the specified
     631             :     /// parent scope.
     632             :     /// \param Scope       Namespace scope
     633             :     /// \param Name        Name of this namespace
     634             :     /// \param ExportSymbols True for C++ inline namespaces.
     635             :     DINamespace *createNameSpace(DIScope *Scope, StringRef Name,
     636             :                                  bool ExportSymbols);
     637             : 
     638             :     /// This creates new descriptor for a module with the specified
     639             :     /// parent scope.
     640             :     /// \param Scope       Parent scope
     641             :     /// \param Name        Name of this module
     642             :     /// \param ConfigurationMacros
     643             :     ///                    A space-separated shell-quoted list of -D macro
     644             :     ///                    definitions as they would appear on a command line.
     645             :     /// \param IncludePath The path to the module map file.
     646             :     /// \param ISysRoot    The clang system root (value of -isysroot).
     647             :     DIModule *createModule(DIScope *Scope, StringRef Name,
     648             :                            StringRef ConfigurationMacros,
     649             :                            StringRef IncludePath,
     650             :                            StringRef ISysRoot);
     651             : 
     652             :     /// This creates a descriptor for a lexical block with a new file
     653             :     /// attached. This merely extends the existing
     654             :     /// lexical block as it crosses a file.
     655             :     /// \param Scope       Lexical block.
     656             :     /// \param File        Source file.
     657             :     /// \param Discriminator DWARF path discriminator value.
     658             :     DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
     659             :                                                unsigned Discriminator = 0);
     660             : 
     661             :     /// This creates a descriptor for a lexical block with the
     662             :     /// specified parent context.
     663             :     /// \param Scope         Parent lexical scope.
     664             :     /// \param File          Source file.
     665             :     /// \param Line          Line number.
     666             :     /// \param Col           Column number.
     667             :     DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
     668             :                                        unsigned Line, unsigned Col);
     669             : 
     670             :     /// Create a descriptor for an imported module.
     671             :     /// \param Context The scope this module is imported into
     672             :     /// \param NS      The namespace being imported here.
     673             :     /// \param File    File where the declaration is located.
     674             :     /// \param Line    Line number of the declaration.
     675             :     DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
     676             :                                            DIFile *File, unsigned Line);
     677             : 
     678             :     /// Create a descriptor for an imported module.
     679             :     /// \param Context The scope this module is imported into.
     680             :     /// \param NS      An aliased namespace.
     681             :     /// \param File    File where the declaration is located.
     682             :     /// \param Line    Line number of the declaration.
     683             :     DIImportedEntity *createImportedModule(DIScope *Context,
     684             :                                            DIImportedEntity *NS, DIFile *File,
     685             :                                            unsigned Line);
     686             : 
     687             :     /// Create a descriptor for an imported module.
     688             :     /// \param Context The scope this module is imported into.
     689             :     /// \param M       The module being imported here
     690             :     /// \param File    File where the declaration is located.
     691             :     /// \param Line    Line number of the declaration.
     692             :     DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
     693             :                                            DIFile *File, unsigned Line);
     694             : 
     695             :     /// Create a descriptor for an imported function.
     696             :     /// \param Context The scope this module is imported into.
     697             :     /// \param Decl    The declaration (or definition) of a function, type, or
     698             :     ///                variable.
     699             :     /// \param File    File where the declaration is located.
     700             :     /// \param Line    Line number of the declaration.
     701             :     DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
     702             :                                                 DIFile *File, unsigned Line,
     703             :                                                 StringRef Name = "");
     704             : 
     705             :     /// Insert a new llvm.dbg.declare intrinsic call.
     706             :     /// \param Storage     llvm::Value of the variable
     707             :     /// \param VarInfo     Variable's debug info descriptor.
     708             :     /// \param Expr        A complex location expression.
     709             :     /// \param DL          Debug info location.
     710             :     /// \param InsertAtEnd Location for the new intrinsic.
     711             :     Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
     712             :                                DIExpression *Expr, const DILocation *DL,
     713             :                                BasicBlock *InsertAtEnd);
     714             : 
     715             :     /// Insert a new llvm.dbg.declare intrinsic call.
     716             :     /// \param Storage      llvm::Value of the variable
     717             :     /// \param VarInfo      Variable's debug info descriptor.
     718             :     /// \param Expr         A complex location expression.
     719             :     /// \param DL           Debug info location.
     720             :     /// \param InsertBefore Location for the new intrinsic.
     721             :     Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
     722             :                                DIExpression *Expr, const DILocation *DL,
     723             :                                Instruction *InsertBefore);
     724             : 
     725             :     /// Insert a new llvm.dbg.value intrinsic call.
     726             :     /// \param Val          llvm::Value of the variable
     727             :     /// \param VarInfo      Variable's debug info descriptor.
     728             :     /// \param Expr         A complex location expression.
     729             :     /// \param DL           Debug info location.
     730             :     /// \param InsertAtEnd Location for the new intrinsic.
     731             :     Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
     732             :                                          DILocalVariable *VarInfo,
     733             :                                          DIExpression *Expr,
     734             :                                          const DILocation *DL,
     735             :                                          BasicBlock *InsertAtEnd);
     736             : 
     737             :     /// Insert a new llvm.dbg.value intrinsic call.
     738             :     /// \param Val          llvm::Value of the variable
     739             :     /// \param VarInfo      Variable's debug info descriptor.
     740             :     /// \param Expr         A complex location expression.
     741             :     /// \param DL           Debug info location.
     742             :     /// \param InsertBefore Location for the new intrinsic.
     743             :     Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
     744             :                                          DILocalVariable *VarInfo,
     745             :                                          DIExpression *Expr,
     746             :                                          const DILocation *DL,
     747             :                                          Instruction *InsertBefore);
     748             : 
     749             :     /// Replace the vtable holder in the given composite type.
     750             :     ///
     751             :     /// If this creates a self reference, it may orphan some unresolved cycles
     752             :     /// in the operands of \c T, so \a DIBuilder needs to track that.
     753             :     void replaceVTableHolder(DICompositeType *&T,
     754             :                              DICompositeType *VTableHolder);
     755             : 
     756             :     /// Replace arrays on a composite type.
     757             :     ///
     758             :     /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
     759             :     /// has a self-reference -- \a DIBuilder needs to track the array to
     760             :     /// resolve cycles.
     761             :     void replaceArrays(DICompositeType *&T, DINodeArray Elements,
     762             :                        DINodeArray TParams = DINodeArray());
     763             : 
     764             :     /// Replace a temporary node.
     765             :     ///
     766             :     /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
     767             :     /// Replacement.
     768             :     ///
     769             :     /// If \c Replacement is the same as \c N.get(), instead call \a
     770             :     /// MDNode::replaceWithUniqued().  In this case, the uniqued node could
     771             :     /// have a different address, so we return the final address.
     772             :     template <class NodeTy>
     773        6775 :     NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
     774        6775 :       if (N.get() == Replacement)
     775       32575 :         return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
     776             : 
     777         260 :       N->replaceAllUsesWith(Replacement);
     778             :       return Replacement;
     779             :     }
     780             :   };
     781             : 
     782             :   // Create wrappers for C Binding types (see CBindingWrapping.h).
     783             :   DEFINE_ISA_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef)
     784             : 
     785             : } // end namespace llvm
     786             : 
     787             : #endif // LLVM_IR_DIBUILDER_H

Generated by: LCOV version 1.13