DebugInfo.h 49 KB

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