DebugInfo.h 55 KB

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