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