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