DebugInfo.h 54 KB

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