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

Generated by: LCOV version 1.13