1 //===------------ DebugInfo.h - LLVM C API Debug Info API -----------------===//
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 declares the C API endpoints for generating DWARF Debug Info
11 ///
12 /// Note: This interface is experimental. It is *NOT* stable, and may be
13 ///       changed without warning.
14 ///
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_C_DEBUGINFO_H
18 #define LLVM_C_DEBUGINFO_H
19 
20 #include "llvm-c/Core.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /**
27  * Debug info flags.
28  */
29 typedef enum {
30   LLVMDIFlagZero = 0,
31   LLVMDIFlagPrivate = 1,
32   LLVMDIFlagProtected = 2,
33   LLVMDIFlagPublic = 3,
34   LLVMDIFlagFwdDecl = 1 << 2,
35   LLVMDIFlagAppleBlock = 1 << 3,
36   LLVMDIFlagBlockByrefStruct = 1 << 4,
37   LLVMDIFlagVirtual = 1 << 5,
38   LLVMDIFlagArtificial = 1 << 6,
39   LLVMDIFlagExplicit = 1 << 7,
40   LLVMDIFlagPrototyped = 1 << 8,
41   LLVMDIFlagObjcClassComplete = 1 << 9,
42   LLVMDIFlagObjectPointer = 1 << 10,
43   LLVMDIFlagVector = 1 << 11,
44   LLVMDIFlagStaticMember = 1 << 12,
45   LLVMDIFlagLValueReference = 1 << 13,
46   LLVMDIFlagRValueReference = 1 << 14,
47   LLVMDIFlagReserved = 1 << 15,
48   LLVMDIFlagSingleInheritance = 1 << 16,
49   LLVMDIFlagMultipleInheritance = 2 << 16,
50   LLVMDIFlagVirtualInheritance = 3 << 16,
51   LLVMDIFlagIntroducedVirtual = 1 << 18,
52   LLVMDIFlagBitField = 1 << 19,
53   LLVMDIFlagNoReturn = 1 << 20,
54   LLVMDIFlagMainSubprogram = 1 << 21,
55   LLVMDIFlagTypePassByValue = 1 << 22,
56   LLVMDIFlagTypePassByReference = 1 << 23,
57   LLVMDIFlagFixedEnum = 1 << 24,
58   LLVMDIFlagThunk = 1 << 25,
59   LLVMDIFlagTrivial = 1 << 26,
60   LLVMDIFlagBigEndian = 1 << 27,
61   LLVMDIFlagLittleEndian = 1 << 28,
62   LLVMDIFlagIndirectVirtualBase = (1 << 2) | (1 << 5),
63   LLVMDIFlagAccessibility = LLVMDIFlagPrivate | LLVMDIFlagProtected |
64                             LLVMDIFlagPublic,
65   LLVMDIFlagPtrToMemberRep = LLVMDIFlagSingleInheritance |
66                              LLVMDIFlagMultipleInheritance |
67                              LLVMDIFlagVirtualInheritance
68 } LLVMDIFlags;
69 
70 /**
71  * Source languages known by DWARF.
72  */
73 typedef enum {
74   LLVMDWARFSourceLanguageC89,
75   LLVMDWARFSourceLanguageC,
76   LLVMDWARFSourceLanguageAda83,
77   LLVMDWARFSourceLanguageC_plus_plus,
78   LLVMDWARFSourceLanguageCobol74,
79   LLVMDWARFSourceLanguageCobol85,
80   LLVMDWARFSourceLanguageFortran77,
81   LLVMDWARFSourceLanguageFortran90,
82   LLVMDWARFSourceLanguagePascal83,
83   LLVMDWARFSourceLanguageModula2,
84   // New in DWARF v3:
85   LLVMDWARFSourceLanguageJava,
86   LLVMDWARFSourceLanguageC99,
87   LLVMDWARFSourceLanguageAda95,
88   LLVMDWARFSourceLanguageFortran95,
89   LLVMDWARFSourceLanguagePLI,
90   LLVMDWARFSourceLanguageObjC,
91   LLVMDWARFSourceLanguageObjC_plus_plus,
92   LLVMDWARFSourceLanguageUPC,
93   LLVMDWARFSourceLanguageD,
94   // New in DWARF v4:
95   LLVMDWARFSourceLanguagePython,
96   // New in DWARF v5:
97   LLVMDWARFSourceLanguageOpenCL,
98   LLVMDWARFSourceLanguageGo,
99   LLVMDWARFSourceLanguageModula3,
100   LLVMDWARFSourceLanguageHaskell,
101   LLVMDWARFSourceLanguageC_plus_plus_03,
102   LLVMDWARFSourceLanguageC_plus_plus_11,
103   LLVMDWARFSourceLanguageOCaml,
104   LLVMDWARFSourceLanguageRust,
105   LLVMDWARFSourceLanguageC11,
106   LLVMDWARFSourceLanguageSwift,
107   LLVMDWARFSourceLanguageJulia,
108   LLVMDWARFSourceLanguageDylan,
109   LLVMDWARFSourceLanguageC_plus_plus_14,
110   LLVMDWARFSourceLanguageFortran03,
111   LLVMDWARFSourceLanguageFortran08,
112   LLVMDWARFSourceLanguageRenderScript,
113   LLVMDWARFSourceLanguageBLISS,
114   // Vendor extensions:
115   LLVMDWARFSourceLanguageMips_Assembler,
116   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
117   LLVMDWARFSourceLanguageBORLAND_Delphi
118 } LLVMDWARFSourceLanguage;
119 
120 /**
121  * The amount of debug information to emit.
122  */
123 typedef enum {
124     LLVMDWARFEmissionNone = 0,
125     LLVMDWARFEmissionFull,
126     LLVMDWARFEmissionLineTablesOnly
127 } LLVMDWARFEmissionKind;
128 
129 /**
130  * The kind of metadata nodes.
131  */
132 enum {
133   LLVMMDStringMetadataKind,
134   LLVMConstantAsMetadataMetadataKind,
135   LLVMLocalAsMetadataMetadataKind,
136   LLVMDistinctMDOperandPlaceholderMetadataKind,
137   LLVMMDTupleMetadataKind,
138   LLVMDILocationMetadataKind,
139   LLVMDIExpressionMetadataKind,
140   LLVMDIGlobalVariableExpressionMetadataKind,
141   LLVMGenericDINodeMetadataKind,
142   LLVMDISubrangeMetadataKind,
143   LLVMDIEnumeratorMetadataKind,
144   LLVMDIBasicTypeMetadataKind,
145   LLVMDIDerivedTypeMetadataKind,
146   LLVMDICompositeTypeMetadataKind,
147   LLVMDISubroutineTypeMetadataKind,
148   LLVMDIFileMetadataKind,
149   LLVMDICompileUnitMetadataKind,
150   LLVMDISubprogramMetadataKind,
151   LLVMDILexicalBlockMetadataKind,
152   LLVMDILexicalBlockFileMetadataKind,
153   LLVMDINamespaceMetadataKind,
154   LLVMDIModuleMetadataKind,
155   LLVMDITemplateTypeParameterMetadataKind,
156   LLVMDITemplateValueParameterMetadataKind,
157   LLVMDIGlobalVariableMetadataKind,
158   LLVMDILocalVariableMetadataKind,
159   LLVMDILabelMetadataKind,
160   LLVMDIObjCPropertyMetadataKind,
161   LLVMDIImportedEntityMetadataKind,
162   LLVMDIMacroMetadataKind,
163   LLVMDIMacroFileMetadataKind
164 };
165 typedef unsigned LLVMMetadataKind;
166 
167 /**
168  * An LLVM DWARF type encoding.
169  */
170 typedef unsigned LLVMDWARFTypeEncoding;
171 
172 /**
173  * The current debug metadata version number.
174  */
175 unsigned LLVMDebugMetadataVersion(void);
176 
177 /**
178  * The version of debug metadata that's present in the provided \c Module.
179  */
180 unsigned LLVMGetModuleDebugMetadataVersion(LLVMModuleRef Module);
181 
182 /**
183  * Strip debug info in the module if it exists.
184  * To do this, we remove all calls to the debugger intrinsics and any named
185  * metadata for debugging. We also remove debug locations for instructions.
186  * Return true if module is modified.
187  */
188 LLVMBool LLVMStripModuleDebugInfo(LLVMModuleRef Module);
189 
190 /**
191  * Construct a builder for a module, and do not allow for unresolved nodes
192  * attached to the module.
193  */
194 LLVMDIBuilderRef LLVMCreateDIBuilderDisallowUnresolved(LLVMModuleRef M);
195 
196 /**
197  * Construct a builder for a module and collect unresolved nodes attached
198  * to the module in order to resolve cycles during a call to
199  * \c LLVMDIBuilderFinalize.
200  */
201 LLVMDIBuilderRef LLVMCreateDIBuilder(LLVMModuleRef M);
202 
203 /**
204  * Deallocates the \c DIBuilder and everything it owns.
205  * @note You must call \c LLVMDIBuilderFinalize before this
206  */
207 void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder);
208 
209 /**
210  * Construct any deferred debug info descriptors.
211  */
212 void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder);
213 
214 /**
215  * A CompileUnit provides an anchor for all debugging
216  * information generated during this instance of compilation.
217  * \param Lang          Source programming language, eg.
218  *                      \c LLVMDWARFSourceLanguageC99
219  * \param FileRef       File info.
220  * \param Producer      Identify the producer of debugging information
221  *                      and code.  Usually this is a compiler
222  *                      version string.
223  * \param ProducerLen   The length of the C string passed to \c Producer.
224  * \param isOptimized   A boolean flag which indicates whether optimization
225  *                      is enabled or not.
226  * \param Flags         This string lists command line options. This
227  *                      string is directly embedded in debug info
228  *                      output which may be used by a tool
229  *                      analyzing generated debugging information.
230  * \param FlagsLen      The length of the C string passed to \c Flags.
231  * \param RuntimeVer    This indicates runtime version for languages like
232  *                      Objective-C.
233  * \param SplitName     The name of the file that we'll split debug info
234  *                      out into.
235  * \param SplitNameLen  The length of the C string passed to \c SplitName.
236  * \param Kind          The kind of debug information to generate.
237  * \param DWOId         The DWOId if this is a split skeleton compile unit.
238  * \param SplitDebugInlining    Whether to emit inline debug info.
239  * \param DebugInfoForProfiling Whether to emit extra debug info for
240  *                              profile collection.
241  */
242 LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(
243     LLVMDIBuilderRef Builder, LLVMDWARFSourceLanguage Lang,
244     LLVMMetadataRef FileRef, const char *Producer, size_t ProducerLen,
245     LLVMBool isOptimized, const char *Flags, size_t FlagsLen,
246     unsigned RuntimeVer, const char *SplitName, size_t SplitNameLen,
247     LLVMDWARFEmissionKind Kind, unsigned DWOId, LLVMBool SplitDebugInlining,
248     LLVMBool DebugInfoForProfiling);
249 
250 /**
251  * Create a file descriptor to hold debugging information for a file.
252  * \param Builder      The \c DIBuilder.
253  * \param Filename     File name.
254  * \param FilenameLen  The length of the C string passed to \c Filename.
255  * \param Directory    Directory.
256  * \param DirectoryLen The length of the C string passed to \c Directory.
257  */
258 LLVMMetadataRef
259 LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename,
260                         size_t FilenameLen, const char *Directory,
261                         size_t DirectoryLen);
262 
263 /**
264  * Creates a new descriptor for a module with the specified parent scope.
265  * \param Builder         The \c DIBuilder.
266  * \param ParentScope     The parent scope containing this module declaration.
267  * \param Name            Module name.
268  * \param NameLen         The length of the C string passed to \c Name.
269  * \param ConfigMacros    A space-separated shell-quoted list of -D macro
270                           definitions as they would appear on a command line.
271  * \param ConfigMacrosLen The length of the C string passed to \c ConfigMacros.
272  * \param IncludePath     The path to the module map file.
273  * \param IncludePathLen  The length of the C string passed to \c IncludePath.
274  * \param ISysRoot        The Clang system root (value of -isysroot).
275  * \param ISysRootLen     The length of the C string passed to \c ISysRoot.
276  */
277 LLVMMetadataRef
278 LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope,
279                           const char *Name, size_t NameLen,
280                           const char *ConfigMacros, size_t ConfigMacrosLen,
281                           const char *IncludePath, size_t IncludePathLen,
282                           const char *ISysRoot, size_t ISysRootLen);
283 
284 /**
285  * Creates a new descriptor for a namespace with the specified parent scope.
286  * \param Builder          The \c DIBuilder.
287  * \param ParentScope      The parent scope containing this module declaration.
288  * \param Name             NameSpace name.
289  * \param NameLen          The length of the C string passed to \c Name.
290  * \param ExportSymbols    Whether or not the namespace exports symbols, e.g.
291  *                         this is true of C++ inline namespaces.
292  */
293 LLVMMetadataRef
294 LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
295                              LLVMMetadataRef ParentScope,
296                              const char *Name, size_t NameLen,
297                              LLVMBool ExportSymbols);
298 
299 /**
300  * Create a new descriptor for the specified subprogram.
301  * \param Builder         The \c DIBuilder.
302  * \param Scope           Function scope.
303  * \param Name            Function name.
304  * \param NameLen         Length of enumeration name.
305  * \param LinkageName     Mangled function name.
306  * \param LinkageNameLen  Length of linkage name.
307  * \param File            File where this variable is defined.
308  * \param LineNo          Line number.
309  * \param Ty              Function type.
310  * \param IsLocalToUnit   True if this function is not externally visible.
311  * \param IsDefinition    True if this is a function definition.
312  * \param ScopeLine       Set to the beginning of the scope this starts
313  * \param Flags           E.g.: \c LLVMDIFlagLValueReference. These flags are
314  *                        used to emit dwarf attributes.
315  * \param IsOptimized     True if optimization is ON.
316  */
317 LLVMMetadataRef LLVMDIBuilderCreateFunction(
318     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
319     size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
320     LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
321     LLVMBool IsLocalToUnit, LLVMBool IsDefinition,
322     unsigned ScopeLine, LLVMDIFlags Flags, LLVMBool IsOptimized);
323 
324 /**
325  * Create a descriptor for a lexical block with the specified parent context.
326  * \param Builder      The \c DIBuilder.
327  * \param Scope        Parent lexical block.
328  * \param File         Source file.
329  * \param Line         The line in the source file.
330  * \param Column       The column in the source file.
331  */
332 LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(
333     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope,
334     LLVMMetadataRef File, unsigned Line, unsigned Column);
335 
336 /**
337  * Create a descriptor for a lexical block with a new file attached.
338  * \param Builder        The \c DIBuilder.
339  * \param Scope          Lexical block.
340  * \param File           Source file.
341  * \param Discriminator  DWARF path discriminator value.
342  */
343 LLVMMetadataRef
344 LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder,
345                                     LLVMMetadataRef Scope,
346                                     LLVMMetadataRef File,
347                                     unsigned Discriminator);
348 
349 /**
350  * Create a descriptor for an imported namespace. Suitable for e.g. C++
351  * using declarations.
352  * \param Builder    The \c DIBuilder.
353  * \param Scope      The scope this module is imported into
354  * \param File       File where the declaration is located.
355  * \param Line       Line number of the declaration.
356  */
357 LLVMMetadataRef
358 LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder,
359                                                LLVMMetadataRef Scope,
360                                                LLVMMetadataRef NS,
361                                                LLVMMetadataRef File,
362                                                unsigned Line);
363 
364 /**
365  * Create a descriptor for an imported module that aliases another
366  * imported entity descriptor.
367  * \param Builder        The \c DIBuilder.
368  * \param Scope          The scope this module is imported into
369  * \param ImportedEntity Previous imported entity to alias.
370  * \param File           File where the declaration is located.
371  * \param Line           Line number of the declaration.
372  */
373 LLVMMetadataRef
374 LLVMDIBuilderCreateImportedModuleFromAlias(LLVMDIBuilderRef Builder,
375                                            LLVMMetadataRef Scope,
376                                            LLVMMetadataRef ImportedEntity,
377                                            LLVMMetadataRef File,
378                                            unsigned Line);
379 
380 /**
381  * Create a descriptor for an imported module.
382  * \param Builder    The \c DIBuilder.
383  * \param Scope      The scope this module is imported into
384  * \param M          The module being imported here
385  * \param File       File where the declaration is located.
386  * \param Line       Line number of the declaration.
387  */
388 LLVMMetadataRef
389 LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder,
390                                             LLVMMetadataRef Scope,
391                                             LLVMMetadataRef M,
392                                             LLVMMetadataRef File,
393                                             unsigned Line);
394 
395 /**
396  * Create a descriptor for an imported function, type, or variable.  Suitable
397  * for e.g. FORTRAN-style USE declarations.
398  * \param Builder    The DIBuilder.
399  * \param Scope      The scope this module is imported into.
400  * \param Decl       The declaration (or definition) of a function, type,
401                      or variable.
402  * \param File       File where the declaration is located.
403  * \param Line       Line number of the declaration.
404  * \param Name       A name that uniquely identifies this imported declaration.
405  * \param NameLen    The length of the C string passed to \c Name.
406  */
407 LLVMMetadataRef
408 LLVMDIBuilderCreateImportedDeclaration(LLVMDIBuilderRef Builder,
409                                        LLVMMetadataRef Scope,
410                                        LLVMMetadataRef Decl,
411                                        LLVMMetadataRef File,
412                                        unsigned Line,
413                                        const char *Name, size_t NameLen);
414 
415 /**
416  * Creates a new DebugLocation that describes a source location.
417  * \param Line The line in the source file.
418  * \param Column The column in the source file.
419  * \param Scope The scope in which the location resides.
420  * \param InlinedAt The scope where this location was inlined, if at all.
421  *                  (optional).
422  * \note If the item to which this location is attached cannot be
423  *       attributed to a source line, pass 0 for the line and column.
424  */
425 LLVMMetadataRef
426 LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line,
427                                  unsigned Column, LLVMMetadataRef Scope,
428                                  LLVMMetadataRef InlinedAt);
429 
430 /**
431  * Get the line number of this debug location.
432  * \param Location     The debug location.
433  *
434  * @see DILocation::getLine()
435  */
436 unsigned LLVMDILocationGetLine(LLVMMetadataRef Location);
437 
438 /**
439  * Get the column number of this debug location.
440  * \param Location     The debug location.
441  *
442  * @see DILocation::getColumn()
443  */
444 unsigned LLVMDILocationGetColumn(LLVMMetadataRef Location);
445 
446 /**
447  * Get the local scope associated with this debug location.
448  * \param Location     The debug location.
449  *
450  * @see DILocation::getScope()
451  */
452 LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location);
453 
454 /**
455  * Create a type array.
456  * \param Builder        The DIBuilder.
457  * \param Data           The type elements.
458  * \param NumElements    Number of type elements.
459  */
460 LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder,
461                                                   LLVMMetadataRef *Data,
462                                                   size_t NumElements);
463 
464 /**
465  * Create subroutine type.
466  * \param Builder        The DIBuilder.
467  * \param File            The file in which the subroutine resides.
468  * \param ParameterTypes  An array of subroutine parameter types. This
469  *                        includes return type at 0th index.
470  * \param NumParameterTypes The number of parameter types in \c ParameterTypes
471  * \param Flags           E.g.: \c LLVMDIFlagLValueReference.
472  *                        These flags are used to emit dwarf attributes.
473  */
474 LLVMMetadataRef
475 LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder,
476                                   LLVMMetadataRef File,
477                                   LLVMMetadataRef *ParameterTypes,
478                                   unsigned NumParameterTypes,
479                                   LLVMDIFlags Flags);
480 
481 /**
482  * Create debugging information entry for an enumeration.
483  * \param Builder        The DIBuilder.
484  * \param Scope          Scope in which this enumeration is defined.
485  * \param Name           Enumeration name.
486  * \param NameLen        Length of enumeration name.
487  * \param File           File where this member is defined.
488  * \param LineNumber     Line number.
489  * \param SizeInBits     Member size.
490  * \param AlignInBits    Member alignment.
491  * \param Elements       Enumeration elements.
492  * \param NumElements    Number of enumeration elements.
493  * \param ClassTy        Underlying type of a C++11/ObjC fixed enum.
494  */
495 LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(
496     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
497     size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
498     uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef *Elements,
499     unsigned NumElements, LLVMMetadataRef ClassTy);
500 
501 /**
502  * Create debugging information entry for a union.
503  * \param Builder      The DIBuilder.
504  * \param Scope        Scope in which this union is defined.
505  * \param Name         Union name.
506  * \param NameLen      Length of union name.
507  * \param File         File where this member is defined.
508  * \param LineNumber   Line number.
509  * \param SizeInBits   Member size.
510  * \param AlignInBits  Member alignment.
511  * \param Flags        Flags to encode member attribute, e.g. private
512  * \param Elements     Union elements.
513  * \param NumElements  Number of union elements.
514  * \param RunTimeLang  Optional parameter, Objective-C runtime version.
515  * \param UniqueId     A unique identifier for the union.
516  * \param UniqueIdLen  Length of unique identifier.
517  */
518 LLVMMetadataRef LLVMDIBuilderCreateUnionType(
519     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
520     size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
521     uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags,
522     LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang,
523     const char *UniqueId, size_t UniqueIdLen);
524 
525 
526 /**
527  * Create debugging information entry for an array.
528  * \param Builder      The DIBuilder.
529  * \param Size         Array size.
530  * \param AlignInBits  Alignment.
531  * \param Ty           Element type.
532  * \param Subscripts   Subscripts.
533  * \param NumSubscripts Number of subscripts.
534  */
535 LLVMMetadataRef
536 LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
537                              uint32_t AlignInBits, LLVMMetadataRef Ty,
538                              LLVMMetadataRef *Subscripts,
539                              unsigned NumSubscripts);
540 
541 /**
542  * Create debugging information entry for a vector type.
543  * \param Builder      The DIBuilder.
544  * \param Size         Vector size.
545  * \param AlignInBits  Alignment.
546  * \param Ty           Element type.
547  * \param Subscripts   Subscripts.
548  * \param NumSubscripts Number of subscripts.
549  */
550 LLVMMetadataRef
551 LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size,
552                               uint32_t AlignInBits, LLVMMetadataRef Ty,
553                               LLVMMetadataRef *Subscripts,
554                               unsigned NumSubscripts);
555 
556 /**
557  * Create a DWARF unspecified type.
558  * \param Builder   The DIBuilder.
559  * \param Name      The unspecified type's name.
560  * \param NameLen   Length of type name.
561  */
562 LLVMMetadataRef
563 LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name,
564                                    size_t NameLen);
565 
566 /**
567  * Create debugging information entry for a basic
568  * type.
569  * \param Builder     The DIBuilder.
570  * \param Name        Type name.
571  * \param NameLen     Length of type name.
572  * \param SizeInBits  Size of the type.
573  * \param Encoding    DWARF encoding code, e.g. \c LLVMDWARFTypeEncoding_float.
574  * \param Flags       Flags to encode optional attribute like endianity
575  */
576 LLVMMetadataRef
577 LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder, const char *Name,
578                              size_t NameLen, uint64_t SizeInBits,
579                              LLVMDWARFTypeEncoding Encoding,
580                              LLVMDIFlags Flags);
581 
582 /**
583  * Create debugging information entry for a pointer.
584  * \param Builder     The DIBuilder.
585  * \param PointeeTy         Type pointed by this pointer.
586  * \param SizeInBits        Size.
587  * \param AlignInBits       Alignment. (optional, pass 0 to ignore)
588  * \param AddressSpace      DWARF address space. (optional, pass 0 to ignore)
589  * \param Name              Pointer type name. (optional)
590  * \param NameLen           Length of pointer type name. (optional)
591  */
592 LLVMMetadataRef LLVMDIBuilderCreatePointerType(
593     LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeTy,
594     uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace,
595     const char *Name, size_t NameLen);
596 
597 /**
598  * Create debugging information entry for a struct.
599  * \param Builder     The DIBuilder.
600  * \param Scope        Scope in which this struct is defined.
601  * \param Name         Struct name.
602  * \param NameLen      Struct name length.
603  * \param File         File where this member is defined.
604  * \param LineNumber   Line number.
605  * \param SizeInBits   Member size.
606  * \param AlignInBits  Member alignment.
607  * \param Flags        Flags to encode member attribute, e.g. private
608  * \param Elements     Struct elements.
609  * \param NumElements  Number of struct elements.
610  * \param RunTimeLang  Optional parameter, Objective-C runtime version.
611  * \param VTableHolder The object containing the vtable for the struct.
612  * \param UniqueId     A unique identifier for the struct.
613  * \param UniqueIdLen  Length of the unique identifier for the struct.
614  */
615 LLVMMetadataRef LLVMDIBuilderCreateStructType(
616     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
617     size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
618     uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags,
619     LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements,
620     unsigned NumElements, unsigned RunTimeLang, LLVMMetadataRef VTableHolder,
621     const char *UniqueId, size_t UniqueIdLen);
622 
623 /**
624  * Create debugging information entry for a member.
625  * \param Builder      The DIBuilder.
626  * \param Scope        Member scope.
627  * \param Name         Member name.
628  * \param NameLen      Length of member name.
629  * \param File         File where this member is defined.
630  * \param LineNo       Line number.
631  * \param SizeInBits   Member size.
632  * \param AlignInBits  Member alignment.
633  * \param OffsetInBits Member offset.
634  * \param Flags        Flags to encode member attribute, e.g. private
635  * \param Ty           Parent type.
636  */
637 LLVMMetadataRef LLVMDIBuilderCreateMemberType(
638     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
639     size_t NameLen, LLVMMetadataRef File, unsigned LineNo,
640     uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
641     LLVMDIFlags Flags, LLVMMetadataRef Ty);
642 
643 /**
644  * Create debugging information entry for a
645  * C++ static data member.
646  * \param Builder      The DIBuilder.
647  * \param Scope        Member scope.
648  * \param Name         Member name.
649  * \param NameLen      Length of member name.
650  * \param File         File where this member is declared.
651  * \param LineNumber   Line number.
652  * \param Type         Type of the static member.
653  * \param Flags        Flags to encode member attribute, e.g. private.
654  * \param ConstantVal  Const initializer of the member.
655  * \param AlignInBits  Member alignment.
656  */
657 LLVMMetadataRef
658 LLVMDIBuilderCreateStaticMemberType(
659     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
660     size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
661     LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal,
662     uint32_t AlignInBits);
663 
664 /**
665  * Create debugging information entry for a pointer to member.
666  * \param Builder      The DIBuilder.
667  * \param PointeeType  Type pointed to by this pointer.
668  * \param ClassType    Type for which this pointer points to members of.
669  * \param SizeInBits   Size.
670  * \param AlignInBits  Alignment.
671  * \param Flags        Flags.
672  */
673 LLVMMetadataRef
674 LLVMDIBuilderCreateMemberPointerType(LLVMDIBuilderRef Builder,
675                                      LLVMMetadataRef PointeeType,
676                                      LLVMMetadataRef ClassType,
677                                      uint64_t SizeInBits,
678                                      uint32_t AlignInBits,
679                                      LLVMDIFlags Flags);
680 /**
681  * Create debugging information entry for Objective-C instance variable.
682  * \param Builder      The DIBuilder.
683  * \param Name         Member name.
684  * \param NameLen      The length of the C string passed to \c Name.
685  * \param File         File where this member is defined.
686  * \param LineNo       Line number.
687  * \param SizeInBits   Member size.
688  * \param AlignInBits  Member alignment.
689  * \param OffsetInBits Member offset.
690  * \param Flags        Flags to encode member attribute, e.g. private
691  * \param Ty           Parent type.
692  * \param PropertyNode Property associated with this ivar.
693  */
694 LLVMMetadataRef
695 LLVMDIBuilderCreateObjCIVar(LLVMDIBuilderRef Builder,
696                             const char *Name, size_t NameLen,
697                             LLVMMetadataRef File, unsigned LineNo,
698                             uint64_t SizeInBits, uint32_t AlignInBits,
699                             uint64_t OffsetInBits, LLVMDIFlags Flags,
700                             LLVMMetadataRef Ty, LLVMMetadataRef PropertyNode);
701 
702 /**
703  * Create debugging information entry for Objective-C property.
704  * \param Builder            The DIBuilder.
705  * \param Name               Property name.
706  * \param NameLen            The length of the C string passed to \c Name.
707  * \param File               File where this property is defined.
708  * \param LineNo             Line number.
709  * \param GetterName         Name of the Objective C property getter selector.
710  * \param GetterNameLen      The length of the C string passed to \c GetterName.
711  * \param SetterName         Name of the Objective C property setter selector.
712  * \param SetterNameLen      The length of the C string passed to \c SetterName.
713  * \param PropertyAttributes Objective C property attributes.
714  * \param Ty                 Type.
715  */
716 LLVMMetadataRef
717 LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
718                                 const char *Name, size_t NameLen,
719                                 LLVMMetadataRef File, unsigned LineNo,
720                                 const char *GetterName, size_t GetterNameLen,
721                                 const char *SetterName, size_t SetterNameLen,
722                                 unsigned PropertyAttributes,
723                                 LLVMMetadataRef Ty);
724 
725 /**
726  * Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
727  * \param Builder   The DIBuilder.
728  * \param Type      The underlying type to which this pointer points.
729  */
730 LLVMMetadataRef
731 LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
732                                      LLVMMetadataRef Type);
733 
734 /**
735  * Create debugging information entry for a qualified
736  * type, e.g. 'const int'.
737  * \param Builder     The DIBuilder.
738  * \param Tag         Tag identifying type,
739  *                    e.g. LLVMDWARFTypeQualifier_volatile_type
740  * \param Type        Base Type.
741  */
742 LLVMMetadataRef
743 LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag,
744                                  LLVMMetadataRef Type);
745 
746 /**
747  * Create debugging information entry for a c++
748  * style reference or rvalue reference type.
749  * \param Builder   The DIBuilder.
750  * \param Tag       Tag identifying type,
751  * \param Type      Base Type.
752  */
753 LLVMMetadataRef
754 LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder, unsigned Tag,
755                                  LLVMMetadataRef Type);
756 
757 /**
758  * Create C++11 nullptr type.
759  * \param Builder   The DIBuilder.
760  */
761 LLVMMetadataRef
762 LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder);
763 
764 /**
765  * Create debugging information entry for a typedef.
766  * \param Builder    The DIBuilder.
767  * \param Type       Original type.
768  * \param Name       Typedef name.
769  * \param File       File where this type is defined.
770  * \param LineNo     Line number.
771  * \param Scope      The surrounding context for the typedef.
772  */
773 LLVMMetadataRef
774 LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
775                            const char *Name, size_t NameLen,
776                            LLVMMetadataRef File, unsigned LineNo,
777                            LLVMMetadataRef Scope);
778 
779 /**
780  * Create debugging information entry to establish inheritance relationship
781  * between two types.
782  * \param Builder       The DIBuilder.
783  * \param Ty            Original type.
784  * \param BaseTy        Base type. Ty is inherits from base.
785  * \param BaseOffset    Base offset.
786  * \param VBPtrOffset  Virtual base pointer offset.
787  * \param Flags         Flags to describe inheritance attribute, e.g. private
788  */
789 LLVMMetadataRef
790 LLVMDIBuilderCreateInheritance(LLVMDIBuilderRef Builder,
791                                LLVMMetadataRef Ty, LLVMMetadataRef BaseTy,
792                                uint64_t BaseOffset, uint32_t VBPtrOffset,
793                                LLVMDIFlags Flags);
794 
795 /**
796  * Create a permanent forward-declared type.
797  * \param Builder             The DIBuilder.
798  * \param Tag                 A unique tag for this type.
799  * \param Name                Type name.
800  * \param NameLen             Length of type name.
801  * \param Scope               Type scope.
802  * \param File                File where this type is defined.
803  * \param Line                Line number where this type is defined.
804  * \param RuntimeLang         Indicates runtime version for languages like
805  *                            Objective-C.
806  * \param SizeInBits          Member size.
807  * \param AlignInBits         Member alignment.
808  * \param UniqueIdentifier    A unique identifier for the type.
809  * \param UniqueIdentifierLen Length of the unique identifier.
810  */
811 LLVMMetadataRef LLVMDIBuilderCreateForwardDecl(
812     LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
813     size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
814     unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
815     const char *UniqueIdentifier, size_t UniqueIdentifierLen);
816 
817 /**
818  * Create a temporary forward-declared type.
819  * \param Builder             The DIBuilder.
820  * \param Tag                 A unique tag for this type.
821  * \param Name                Type name.
822  * \param NameLen             Length of type name.
823  * \param Scope               Type scope.
824  * \param File                File where this type is defined.
825  * \param Line                Line number where this type is defined.
826  * \param RuntimeLang         Indicates runtime version for languages like
827  *                            Objective-C.
828  * \param SizeInBits          Member size.
829  * \param AlignInBits         Member alignment.
830  * \param Flags               Flags.
831  * \param UniqueIdentifier    A unique identifier for the type.
832  * \param UniqueIdentifierLen Length of the unique identifier.
833  */
834 LLVMMetadataRef
835 LLVMDIBuilderCreateReplaceableCompositeType(
836     LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
837     size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
838     unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
839     LLVMDIFlags Flags, const char *UniqueIdentifier,
840     size_t UniqueIdentifierLen);
841 
842 /**
843  * Create debugging information entry for a bit field member.
844  * \param Builder             The DIBuilder.
845  * \param Scope               Member scope.
846  * \param Name                Member name.
847  * \param NameLen             Length of member name.
848  * \param File                File where this member is defined.
849  * \param LineNumber          Line number.
850  * \param SizeInBits          Member size.
851  * \param OffsetInBits        Member offset.
852  * \param StorageOffsetInBits Member storage offset.
853  * \param Flags               Flags to encode member attribute.
854  * \param Type                Parent type.
855  */
856 LLVMMetadataRef
857 LLVMDIBuilderCreateBitFieldMemberType(LLVMDIBuilderRef Builder,
858                                       LLVMMetadataRef Scope,
859                                       const char *Name, size_t NameLen,
860                                       LLVMMetadataRef File, unsigned LineNumber,
861                                       uint64_t SizeInBits,
862                                       uint64_t OffsetInBits,
863                                       uint64_t StorageOffsetInBits,
864                                       LLVMDIFlags Flags, LLVMMetadataRef Type);
865 
866 /**
867  * Create debugging information entry for a class.
868  * \param Scope               Scope in which this class is defined.
869  * \param Name                Class name.
870  * \param NameLen             The length of the C string passed to \c Name.
871  * \param File                File where this member is defined.
872  * \param LineNumber          Line number.
873  * \param SizeInBits          Member size.
874  * \param AlignInBits         Member alignment.
875  * \param OffsetInBits        Member offset.
876  * \param Flags               Flags to encode member attribute, e.g. private.
877  * \param DerivedFrom         Debug info of the base class of this type.
878  * \param Elements            Class members.
879  * \param NumElements         Number of class elements.
880  * \param VTableHolder        Debug info of the base class that contains vtable
881  *                            for this type. This is used in
882  *                            DW_AT_containing_type. See DWARF documentation
883  *                            for more info.
884  * \param TemplateParamsNode  Template type parameters.
885  * \param UniqueIdentifier    A unique identifier for the type.
886  * \param UniqueIdentifierLen Length of the unique identifier.
887  */
888 LLVMMetadataRef LLVMDIBuilderCreateClassType(LLVMDIBuilderRef Builder,
889     LLVMMetadataRef Scope, const char *Name, size_t NameLen,
890     LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
891     uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags,
892     LLVMMetadataRef DerivedFrom,
893     LLVMMetadataRef *Elements, unsigned NumElements,
894     LLVMMetadataRef VTableHolder, LLVMMetadataRef TemplateParamsNode,
895     const char *UniqueIdentifier, size_t UniqueIdentifierLen);
896 
897 /**
898  * Create a uniqued DIType* clone with FlagArtificial set.
899  * \param Builder     The DIBuilder.
900  * \param Type        The underlying type.
901  */
902 LLVMMetadataRef
903 LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder,
904                                   LLVMMetadataRef Type);
905 
906 /**
907  * Get the name of this DIType.
908  * \param DType     The DIType.
909  * \param Length    The length of the returned string.
910  *
911  * @see DIType::getName()
912  */
913 const char *LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length);
914 
915 /**
916  * Get the size of this DIType in bits.
917  * \param DType     The DIType.
918  *
919  * @see DIType::getSizeInBits()
920  */
921 uint64_t LLVMDITypeGetSizeInBits(LLVMMetadataRef DType);
922 
923 /**
924  * Get the offset of this DIType in bits.
925  * \param DType     The DIType.
926  *
927  * @see DIType::getOffsetInBits()
928  */
929 uint64_t LLVMDITypeGetOffsetInBits(LLVMMetadataRef DType);
930 
931 /**
932  * Get the alignment of this DIType in bits.
933  * \param DType     The DIType.
934  *
935  * @see DIType::getAlignInBits()
936  */
937 uint32_t LLVMDITypeGetAlignInBits(LLVMMetadataRef DType);
938 
939 /**
940  * Get the source line where this DIType is declared.
941  * \param DType     The DIType.
942  *
943  * @see DIType::getLine()
944  */
945 unsigned LLVMDITypeGetLine(LLVMMetadataRef DType);
946 
947 /**
948  * Get the flags associated with this DIType.
949  * \param DType     The DIType.
950  *
951  * @see DIType::getFlags()
952  */
953 LLVMDIFlags LLVMDITypeGetFlags(LLVMMetadataRef DType);
954 
955 /**
956  * Create a descriptor for a value range.
957  * \param Builder    The DIBuilder.
958  * \param LowerBound Lower bound of the subrange, e.g. 0 for C, 1 for Fortran.
959  * \param Count      Count of elements in the subrange.
960  */
961 LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder,
962                                                  int64_t LowerBound,
963                                                  int64_t Count);
964 
965 /**
966  * Create an array of DI Nodes.
967  * \param Builder        The DIBuilder.
968  * \param Data           The DI Node elements.
969  * \param NumElements    Number of DI Node elements.
970  */
971 LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder,
972                                               LLVMMetadataRef *Data,
973                                               size_t NumElements);
974 
975 /**
976  * Create a new descriptor for the specified variable which has a complex
977  * address expression for its address.
978  * \param Builder     The DIBuilder.
979  * \param Addr        An array of complex address operations.
980  * \param Length      Length of the address operation array.
981  */
982 LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
983                                               int64_t *Addr, size_t Length);
984 
985 /**
986  * Create a new descriptor for the specified variable that does not have an
987  * address, but does have a constant value.
988  * \param Builder     The DIBuilder.
989  * \param Value       The constant value.
990  */
991 LLVMMetadataRef
992 LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder,
993                                            int64_t Value);
994 
995 /**
996  * Create a new descriptor for the specified variable.
997  * \param Scope       Variable scope.
998  * \param Name        Name of the variable.
999  * \param NameLen     The length of the C string passed to \c Name.
1000  * \param Linkage     Mangled  name of the variable.
1001  * \param LinkLen     The length of the C string passed to \c Linkage.
1002  * \param File        File where this variable is defined.
1003  * \param LineNo      Line number.
1004  * \param Ty          Variable Type.
1005  * \param LocalToUnit Boolean flag indicate whether this variable is
1006  *                    externally visible or not.
1007  * \param Expr        The location of the global relative to the attached
1008  *                    GlobalVariable.
1009  * \param Decl        Reference to the corresponding declaration.
1010  *                    variables.
1011  * \param AlignInBits Variable alignment(or 0 if no alignment attr was
1012  *                    specified)
1013  */
1014 LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
1015     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1016     size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File,
1017     unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
1018     LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits);
1019 /**
1020  * Create a new temporary \c MDNode.  Suitable for use in constructing cyclic
1021  * \c MDNode structures. A temporary \c MDNode is not uniqued, may be RAUW'd,
1022  * and must be manually deleted with \c LLVMDisposeTemporaryMDNode.
1023  * \param Ctx            The context in which to construct the temporary node.
1024  * \param Data           The metadata elements.
1025  * \param NumElements    Number of metadata elements.
1026  */
1027 LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data,
1028                                     size_t NumElements);
1029 
1030 /**
1031  * Deallocate a temporary node.
1032  *
1033  * Calls \c replaceAllUsesWith(nullptr) before deleting, so any remaining
1034  * references will be reset.
1035  * \param TempNode    The temporary metadata node.
1036  */
1037 void LLVMDisposeTemporaryMDNode(LLVMMetadataRef TempNode);
1038 
1039 /**
1040  * Replace all uses of temporary metadata.
1041  * \param TempTargetMetadata    The temporary metadata node.
1042  * \param Replacement           The replacement metadata node.
1043  */
1044 void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef TempTargetMetadata,
1045                                     LLVMMetadataRef Replacement);
1046 
1047 /**
1048  * Create a new descriptor for the specified global variable that is temporary
1049  * and meant to be RAUWed.
1050  * \param Scope       Variable scope.
1051  * \param Name        Name of the variable.
1052  * \param NameLen     The length of the C string passed to \c Name.
1053  * \param Linkage     Mangled  name of the variable.
1054  * \param LnkLen      The length of the C string passed to \c Linkage.
1055  * \param File        File where this variable is defined.
1056  * \param LineNo      Line number.
1057  * \param Ty          Variable Type.
1058  * \param LocalToUnit Boolean flag indicate whether this variable is
1059  *                    externally visible or not.
1060  * \param Decl        Reference to the corresponding declaration.
1061  * \param AlignInBits Variable alignment(or 0 if no alignment attr was
1062  *                    specified)
1063  */
1064 LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
1065     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1066     size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File,
1067     unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
1068     LLVMMetadataRef Decl, uint32_t AlignInBits);
1069 
1070 /**
1071  * Insert a new llvm.dbg.declare intrinsic call before the given instruction.
1072  * \param Builder     The DIBuilder.
1073  * \param Storage     The storage of the variable to declare.
1074  * \param VarInfo     The variable's debug info descriptor.
1075  * \param Expr        A complex location expression for the variable.
1076  * \param DebugLoc    Debug info location.
1077  * \param Instr       Instruction acting as a location for the new intrinsic.
1078  */
1079 LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
1080   LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
1081   LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
1082 
1083 /**
1084  * Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
1085  * block. If the basic block has a terminator instruction, the intrinsic is
1086  * inserted before that terminator instruction.
1087  * \param Builder     The DIBuilder.
1088  * \param Storage     The storage of the variable to declare.
1089  * \param VarInfo     The variable's debug info descriptor.
1090  * \param Expr        A complex location expression for the variable.
1091  * \param DebugLoc    Debug info location.
1092  * \param Block       Basic block acting as a location for the new intrinsic.
1093  */
1094 LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
1095     LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
1096     LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
1097 
1098 /**
1099  * Insert a new llvm.dbg.value intrinsic call before the given instruction.
1100  * \param Builder     The DIBuilder.
1101  * \param Val         The value of the variable.
1102  * \param VarInfo     The variable's debug info descriptor.
1103  * \param Expr        A complex location expression for the variable.
1104  * \param DebugLoc    Debug info location.
1105  * \param Instr       Instruction acting as a location for the new intrinsic.
1106  */
1107 LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
1108                                                LLVMValueRef Val,
1109                                                LLVMMetadataRef VarInfo,
1110                                                LLVMMetadataRef Expr,
1111                                                LLVMMetadataRef DebugLoc,
1112                                                LLVMValueRef Instr);
1113 
1114 /**
1115  * Insert a new llvm.dbg.value intrinsic call at the end of the given basic
1116  * block. If the basic block has a terminator instruction, the intrinsic is
1117  * inserted before that terminator instruction.
1118  * \param Builder     The DIBuilder.
1119  * \param Val         The value of the variable.
1120  * \param VarInfo     The variable's debug info descriptor.
1121  * \param Expr        A complex location expression for the variable.
1122  * \param DebugLoc    Debug info location.
1123  * \param Block       Basic block acting as a location for the new intrinsic.
1124  */
1125 LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder,
1126                                               LLVMValueRef Val,
1127                                               LLVMMetadataRef VarInfo,
1128                                               LLVMMetadataRef Expr,
1129                                               LLVMMetadataRef DebugLoc,
1130                                               LLVMBasicBlockRef Block);
1131 
1132 /**
1133  * Create a new descriptor for a local auto variable.
1134  * \param Builder         The DIBuilder.
1135  * \param Scope           The local scope the variable is declared in.
1136  * \param Name            Variable name.
1137  * \param NameLen         Length of variable name.
1138  * \param File            File where this variable is defined.
1139  * \param LineNo          Line number.
1140  * \param Ty              Metadata describing the type of the variable.
1141  * \param AlwaysPreserve  If true, this descriptor will survive optimizations.
1142  * \param Flags           Flags.
1143  * \param AlignInBits     Variable alignment.
1144  */
1145 LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(
1146     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1147     size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
1148     LLVMBool AlwaysPreserve, LLVMDIFlags Flags, uint32_t AlignInBits);
1149 
1150 /**
1151  * Create a new descriptor for a function parameter variable.
1152  * \param Builder         The DIBuilder.
1153  * \param Scope           The local scope the variable is declared in.
1154  * \param Name            Variable name.
1155  * \param NameLen         Length of variable name.
1156  * \param ArgNo           Unique argument number for this variable; starts at 1.
1157  * \param File            File where this variable is defined.
1158  * \param LineNo          Line number.
1159  * \param Ty              Metadata describing the type of the variable.
1160  * \param AlwaysPreserve  If true, this descriptor will survive optimizations.
1161  * \param Flags           Flags.
1162  */
1163 LLVMMetadataRef LLVMDIBuilderCreateParameterVariable(
1164     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1165     size_t NameLen, unsigned ArgNo, LLVMMetadataRef File, unsigned LineNo,
1166     LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags);
1167 
1168 /**
1169  * Get the metadata of the subprogram attached to a function.
1170  *
1171  * @see llvm::Function::getSubprogram()
1172  */
1173 LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func);
1174 
1175 /**
1176  * Set the subprogram attached to a function.
1177  *
1178  * @see llvm::Function::setSubprogram()
1179  */
1180 void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP);
1181 
1182 /**
1183  * Obtain the enumerated type of a Metadata instance.
1184  *
1185  * @see llvm::Metadata::getMetadataID()
1186  */
1187 LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata);
1188 
1189 #ifdef __cplusplus
1190 } /* end extern "C" */
1191 #endif
1192 
1193 #endif
1194