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