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