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