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