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

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of llvm/include/llvm-c/DebugInfo.h