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