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