DIBuilder.h 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
  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 defines a DIBuilder that is useful for creating debugging
  15. // information entries in LLVM IR form.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_IR_DIBUILDER_H
  19. #define LLVM_IR_DIBUILDER_H
  20. #include "llvm/ADT/ArrayRef.h"
  21. #include "llvm/ADT/DenseMap.h"
  22. #include "llvm/ADT/MapVector.h"
  23. #include "llvm/ADT/Optional.h"
  24. #include "llvm/ADT/SetVector.h"
  25. #include "llvm/ADT/SmallVector.h"
  26. #include "llvm/ADT/StringRef.h"
  27. #include "llvm/IR/DebugInfoMetadata.h"
  28. #include "llvm/IR/TrackingMDRef.h"
  29. #include "llvm/Support/Casting.h"
  30. #include <algorithm>
  31. #include <cstdint>
  32. namespace llvm {
  33. class BasicBlock;
  34. class Constant;
  35. class Function;
  36. class Instruction;
  37. class LLVMContext;
  38. class Module;
  39. class Value;
  40. class DIBuilder {
  41. Module &M;
  42. LLVMContext &VMContext;
  43. DICompileUnit *CUNode; ///< The one compile unit created by this DIBuiler.
  44. Function *DeclareFn; ///< llvm.dbg.declare
  45. Function *ValueFn; ///< llvm.dbg.value
  46. Function *LabelFn; ///< llvm.dbg.label
  47. Function *AddrFn; ///< llvm.dbg.addr
  48. SmallVector<Metadata *, 4> AllEnumTypes;
  49. /// Track the RetainTypes, since they can be updated later on.
  50. SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
  51. SmallVector<Metadata *, 4> AllSubprograms;
  52. SmallVector<Metadata *, 4> AllGVs;
  53. SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
  54. /// Map Macro parent (which can be DIMacroFile or nullptr) to a list of
  55. /// Metadata all of type DIMacroNode.
  56. /// DIMacroNode's with nullptr parent are DICompileUnit direct children.
  57. MapVector<MDNode *, SetVector<Metadata *>> AllMacrosPerParent;
  58. /// Track nodes that may be unresolved.
  59. SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
  60. bool AllowUnresolvedNodes;
  61. /// Each subprogram's preserved local variables.
  62. ///
  63. /// Do not use a std::vector. Some versions of libc++ apparently copy
  64. /// instead of move on grow operations, and TrackingMDRef is expensive to
  65. /// copy.
  66. DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables;
  67. /// Each subprogram's preserved labels.
  68. DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedLabels;
  69. /// Create a temporary.
  70. ///
  71. /// Create an \a temporary node and track it in \a UnresolvedNodes.
  72. void trackIfUnresolved(MDNode *N);
  73. /// Internal helper for insertDeclare.
  74. Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
  75. DIExpression *Expr, const DILocation *DL,
  76. BasicBlock *InsertBB, Instruction *InsertBefore);
  77. /// Internal helper for insertLabel.
  78. Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
  79. BasicBlock *InsertBB, Instruction *InsertBefore);
  80. /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
  81. Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
  82. DILocalVariable *VarInfo,
  83. DIExpression *Expr, const DILocation *DL,
  84. BasicBlock *InsertBB,
  85. Instruction *InsertBefore);
  86. /// Internal helper for insertDbgValueIntrinsic.
  87. Instruction *
  88. insertDbgValueIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo,
  89. DIExpression *Expr, const DILocation *DL,
  90. BasicBlock *InsertBB, Instruction *InsertBefore);
  91. /// Internal helper for insertDbgAddrIntrinsic.
  92. Instruction *
  93. insertDbgAddrIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo,
  94. DIExpression *Expr, const DILocation *DL,
  95. BasicBlock *InsertBB, Instruction *InsertBefore);
  96. public:
  97. /// Construct a builder for a module.
  98. ///
  99. /// If \c AllowUnresolved, collect unresolved nodes attached to the module
  100. /// in order to resolve cycles during \a finalize().
  101. ///
  102. /// If \p CU is given a value other than nullptr, then set \p CUNode to CU.
  103. explicit DIBuilder(Module &M, bool AllowUnresolved = true,
  104. DICompileUnit *CU = nullptr);
  105. DIBuilder(const DIBuilder &) = delete;
  106. DIBuilder &operator=(const DIBuilder &) = delete;
  107. /// Construct any deferred debug info descriptors.
  108. void finalize();
  109. /// Finalize a specific subprogram - no new variables may be added to this
  110. /// subprogram afterwards.
  111. void finalizeSubprogram(DISubprogram *SP);
  112. /// A CompileUnit provides an anchor for all debugging
  113. /// information generated during this instance of compilation.
  114. /// \param Lang Source programming language, eg. dwarf::DW_LANG_C99
  115. /// \param File File info.
  116. /// \param Producer Identify the producer of debugging information
  117. /// and code. Usually this is a compiler
  118. /// version string.
  119. /// \param isOptimized A boolean flag which indicates whether optimization
  120. /// is enabled or not.
  121. /// \param Flags This string lists command line options. This
  122. /// string is directly embedded in debug info
  123. /// output which may be used by a tool
  124. /// analyzing generated debugging information.
  125. /// \param RV This indicates runtime version for languages like
  126. /// Objective-C.
  127. /// \param SplitName The name of the file that we'll split debug info
  128. /// out into.
  129. /// \param Kind The kind of debug information to generate.
  130. /// \param DWOId The DWOId if this is a split skeleton compile unit.
  131. /// \param SplitDebugInlining Whether to emit inline debug info.
  132. /// \param DebugInfoForProfiling Whether to emit extra debug info for
  133. /// profile collection.
  134. /// \param NameTableKind Whether to emit .debug_gnu_pubnames,
  135. /// .debug_pubnames, or no pubnames at all.
  136. /// \param SysRoot The clang system root (value of -isysroot).
  137. /// \param SDK The SDK name. On Darwin, this is the last component
  138. /// of the sysroot.
  139. DICompileUnit *
  140. createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer,
  141. bool isOptimized, StringRef Flags, unsigned RV,
  142. StringRef SplitName = StringRef(),
  143. DICompileUnit::DebugEmissionKind Kind =
  144. DICompileUnit::DebugEmissionKind::FullDebug,
  145. uint64_t DWOId = 0, bool SplitDebugInlining = true,
  146. bool DebugInfoForProfiling = false,
  147. DICompileUnit::DebugNameTableKind NameTableKind =
  148. DICompileUnit::DebugNameTableKind::Default,
  149. bool RangesBaseAddress = false, StringRef SysRoot = {},
  150. StringRef SDK = {});
  151. /// Create a file descriptor to hold debugging information for a file.
  152. /// \param Filename File name.
  153. /// \param Directory Directory.
  154. /// \param Checksum Optional checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.)
  155. /// and value.
  156. /// \param Source Optional source text.
  157. DIFile *
  158. createFile(StringRef Filename, StringRef Directory,
  159. Optional<DIFile::ChecksumInfo<StringRef>> Checksum = None,
  160. Optional<StringRef> Source = None);
  161. /// Create debugging information entry for a macro.
  162. /// \param Parent Macro parent (could be nullptr).
  163. /// \param Line Source line number where the macro is defined.
  164. /// \param MacroType DW_MACINFO_define or DW_MACINFO_undef.
  165. /// \param Name Macro name.
  166. /// \param Value Macro value.
  167. DIMacro *createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType,
  168. StringRef Name, StringRef Value = StringRef());
  169. /// Create debugging information temporary entry for a macro file.
  170. /// List of macro node direct children will be calculated by DIBuilder,
  171. /// using the \p Parent relationship.
  172. /// \param Parent Macro file parent (could be nullptr).
  173. /// \param Line Source line number where the macro file is included.
  174. /// \param File File descriptor containing the name of the macro file.
  175. DIMacroFile *createTempMacroFile(DIMacroFile *Parent, unsigned Line,
  176. DIFile *File);
  177. /// Create a single enumerator value.
  178. DIEnumerator *createEnumerator(StringRef Name, const APSInt &Value);
  179. DIEnumerator *createEnumerator(StringRef Name, uint64_t Val,
  180. bool IsUnsigned = false);
  181. /// Create a DWARF unspecified type.
  182. DIBasicType *createUnspecifiedType(StringRef Name);
  183. /// Create C++11 nullptr type.
  184. DIBasicType *createNullPtrType();
  185. /// Create debugging information entry for a basic
  186. /// type.
  187. /// \param Name Type name.
  188. /// \param SizeInBits Size of the type.
  189. /// \param Encoding DWARF encoding code, e.g., dwarf::DW_ATE_float.
  190. /// \param Flags Optional DWARF attributes, e.g., DW_AT_endianity.
  191. DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
  192. unsigned Encoding,
  193. DINode::DIFlags Flags = DINode::FlagZero);
  194. /// Create debugging information entry for a string
  195. /// type.
  196. /// \param Name Type name.
  197. /// \param SizeInBits Size of the type.
  198. DIStringType *createStringType(StringRef Name, uint64_t SizeInBits);
  199. /// Create debugging information entry for a qualified
  200. /// type, e.g. 'const int'.
  201. /// \param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
  202. /// \param FromTy Base Type.
  203. DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
  204. /// Create debugging information entry for a pointer.
  205. /// \param PointeeTy Type pointed by this pointer.
  206. /// \param SizeInBits Size.
  207. /// \param AlignInBits Alignment. (optional)
  208. /// \param DWARFAddressSpace DWARF address space. (optional)
  209. /// \param Name Pointer type name. (optional)
  210. /// \param Annotations Member annotations.
  211. DIDerivedType *
  212. createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
  213. uint32_t AlignInBits = 0,
  214. Optional<unsigned> DWARFAddressSpace = None,
  215. StringRef Name = "", DINodeArray Annotations = nullptr);
  216. /// Create debugging information entry for a pointer to member.
  217. /// \param PointeeTy Type pointed to by this pointer.
  218. /// \param SizeInBits Size.
  219. /// \param AlignInBits Alignment. (optional)
  220. /// \param Class Type for which this pointer points to members of.
  221. DIDerivedType *
  222. createMemberPointerType(DIType *PointeeTy, DIType *Class,
  223. uint64_t SizeInBits, uint32_t AlignInBits = 0,
  224. DINode::DIFlags Flags = DINode::FlagZero);
  225. /// Create debugging information entry for a c++
  226. /// style reference or rvalue reference type.
  227. DIDerivedType *createReferenceType(unsigned Tag, DIType *RTy,
  228. uint64_t SizeInBits = 0,
  229. uint32_t AlignInBits = 0,
  230. Optional<unsigned> DWARFAddressSpace =
  231. None);
  232. /// Create debugging information entry for a typedef.
  233. /// \param Ty Original type.
  234. /// \param Name Typedef name.
  235. /// \param File File where this type is defined.
  236. /// \param LineNo Line number.
  237. /// \param Context The surrounding context for the typedef.
  238. /// \param AlignInBits Alignment. (optional)
  239. /// \param Annotations Annotations. (optional)
  240. DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
  241. unsigned LineNo, DIScope *Context,
  242. uint32_t AlignInBits = 0,
  243. DINodeArray Annotations = nullptr);
  244. /// Create debugging information entry for a 'friend'.
  245. DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
  246. /// Create debugging information entry to establish
  247. /// inheritance relationship between two types.
  248. /// \param Ty Original type.
  249. /// \param BaseTy Base type. Ty is inherits from base.
  250. /// \param BaseOffset Base offset.
  251. /// \param VBPtrOffset Virtual base pointer offset.
  252. /// \param Flags Flags to describe inheritance attribute,
  253. /// e.g. private
  254. DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
  255. uint64_t BaseOffset, uint32_t VBPtrOffset,
  256. DINode::DIFlags Flags);
  257. /// Create debugging information entry for a member.
  258. /// \param Scope Member scope.
  259. /// \param Name Member name.
  260. /// \param File File where this member is defined.
  261. /// \param LineNo Line number.
  262. /// \param SizeInBits Member size.
  263. /// \param AlignInBits Member alignment.
  264. /// \param OffsetInBits Member offset.
  265. /// \param Flags Flags to encode member attribute, e.g. private
  266. /// \param Ty Parent type.
  267. /// \param Annotations Member annotations.
  268. DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
  269. DIFile *File, unsigned LineNo,
  270. uint64_t SizeInBits, uint32_t AlignInBits,
  271. uint64_t OffsetInBits,
  272. DINode::DIFlags Flags, DIType *Ty,
  273. DINodeArray Annotations = nullptr);
  274. /// Create debugging information entry for a variant. A variant
  275. /// normally should be a member of a variant part.
  276. /// \param Scope Member scope.
  277. /// \param Name Member name.
  278. /// \param File File where this member is defined.
  279. /// \param LineNo Line number.
  280. /// \param SizeInBits Member size.
  281. /// \param AlignInBits Member alignment.
  282. /// \param OffsetInBits Member offset.
  283. /// \param Flags Flags to encode member attribute, e.g. private
  284. /// \param Discriminant The discriminant for this branch; null for
  285. /// the default branch
  286. /// \param Ty Parent type.
  287. DIDerivedType *createVariantMemberType(DIScope *Scope, StringRef Name,
  288. DIFile *File, unsigned LineNo,
  289. uint64_t SizeInBits,
  290. uint32_t AlignInBits,
  291. uint64_t OffsetInBits,
  292. Constant *Discriminant,
  293. DINode::DIFlags Flags, DIType *Ty);
  294. /// Create debugging information entry for a bit field member.
  295. /// \param Scope Member scope.
  296. /// \param Name Member name.
  297. /// \param File File where this member is defined.
  298. /// \param LineNo Line number.
  299. /// \param SizeInBits Member size.
  300. /// \param OffsetInBits Member offset.
  301. /// \param StorageOffsetInBits Member storage offset.
  302. /// \param Flags Flags to encode member attribute.
  303. /// \param Ty Parent type.
  304. /// \param Annotations Member annotations.
  305. DIDerivedType *createBitFieldMemberType(DIScope *Scope, StringRef Name,
  306. DIFile *File, unsigned LineNo,
  307. uint64_t SizeInBits,
  308. uint64_t OffsetInBits,
  309. uint64_t StorageOffsetInBits,
  310. DINode::DIFlags Flags, DIType *Ty,
  311. DINodeArray Annotations = nullptr);
  312. /// Create debugging information entry for a
  313. /// C++ static data member.
  314. /// \param Scope Member scope.
  315. /// \param Name Member name.
  316. /// \param File File where this member is declared.
  317. /// \param LineNo Line number.
  318. /// \param Ty Type of the static member.
  319. /// \param Flags Flags to encode member attribute, e.g. private.
  320. /// \param Val Const initializer of the member.
  321. /// \param AlignInBits Member alignment.
  322. DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
  323. DIFile *File, unsigned LineNo,
  324. DIType *Ty, DINode::DIFlags Flags,
  325. Constant *Val,
  326. uint32_t AlignInBits = 0);
  327. /// Create debugging information entry for Objective-C
  328. /// instance variable.
  329. /// \param Name Member name.
  330. /// \param File File where this member is defined.
  331. /// \param LineNo Line number.
  332. /// \param SizeInBits Member size.
  333. /// \param AlignInBits Member alignment.
  334. /// \param OffsetInBits Member offset.
  335. /// \param Flags Flags to encode member attribute, e.g. private
  336. /// \param Ty Parent type.
  337. /// \param PropertyNode Property associated with this ivar.
  338. DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
  339. uint64_t SizeInBits, uint32_t AlignInBits,
  340. uint64_t OffsetInBits, DINode::DIFlags Flags,
  341. DIType *Ty, MDNode *PropertyNode);
  342. /// Create debugging information entry for Objective-C
  343. /// property.
  344. /// \param Name Property name.
  345. /// \param File File where this property is defined.
  346. /// \param LineNumber Line number.
  347. /// \param GetterName Name of the Objective C property getter selector.
  348. /// \param SetterName Name of the Objective C property setter selector.
  349. /// \param PropertyAttributes Objective C property attributes.
  350. /// \param Ty Type.
  351. DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
  352. unsigned LineNumber,
  353. StringRef GetterName,
  354. StringRef SetterName,
  355. unsigned PropertyAttributes, DIType *Ty);
  356. /// Create debugging information entry for a class.
  357. /// \param Scope Scope in which this class is defined.
  358. /// \param Name class name.
  359. /// \param File File where this member is defined.
  360. /// \param LineNumber Line number.
  361. /// \param SizeInBits Member size.
  362. /// \param AlignInBits Member alignment.
  363. /// \param OffsetInBits Member offset.
  364. /// \param Flags Flags to encode member attribute, e.g. private
  365. /// \param Elements class members.
  366. /// \param VTableHolder Debug info of the base class that contains vtable
  367. /// for this type. This is used in
  368. /// DW_AT_containing_type. See DWARF documentation
  369. /// for more info.
  370. /// \param TemplateParms Template type parameters.
  371. /// \param UniqueIdentifier A unique identifier for the class.
  372. DICompositeType *createClassType(
  373. DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
  374. uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
  375. DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
  376. DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
  377. StringRef UniqueIdentifier = "");
  378. /// Create debugging information entry for a struct.
  379. /// \param Scope Scope in which this struct is defined.
  380. /// \param Name Struct name.
  381. /// \param File File where this member is defined.
  382. /// \param LineNumber Line number.
  383. /// \param SizeInBits Member size.
  384. /// \param AlignInBits Member alignment.
  385. /// \param Flags Flags to encode member attribute, e.g. private
  386. /// \param Elements Struct elements.
  387. /// \param RunTimeLang Optional parameter, Objective-C runtime version.
  388. /// \param UniqueIdentifier A unique identifier for the struct.
  389. DICompositeType *createStructType(
  390. DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
  391. uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
  392. DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
  393. DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
  394. /// Create debugging information entry for an union.
  395. /// \param Scope Scope in which this union is defined.
  396. /// \param Name Union name.
  397. /// \param File File where this member is defined.
  398. /// \param LineNumber Line number.
  399. /// \param SizeInBits Member size.
  400. /// \param AlignInBits Member alignment.
  401. /// \param Flags Flags to encode member attribute, e.g. private
  402. /// \param Elements Union elements.
  403. /// \param RunTimeLang Optional parameter, Objective-C runtime version.
  404. /// \param UniqueIdentifier A unique identifier for the union.
  405. DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
  406. DIFile *File, unsigned LineNumber,
  407. uint64_t SizeInBits, uint32_t AlignInBits,
  408. DINode::DIFlags Flags,
  409. DINodeArray Elements,
  410. unsigned RunTimeLang = 0,
  411. StringRef UniqueIdentifier = "");
  412. /// Create debugging information entry for a variant part. A
  413. /// variant part normally has a discriminator (though this is not
  414. /// required) and a number of variant children.
  415. /// \param Scope Scope in which this union is defined.
  416. /// \param Name Union name.
  417. /// \param File File where this member is defined.
  418. /// \param LineNumber Line number.
  419. /// \param SizeInBits Member size.
  420. /// \param AlignInBits Member alignment.
  421. /// \param Flags Flags to encode member attribute, e.g. private
  422. /// \param Discriminator Discriminant member
  423. /// \param Elements Variant elements.
  424. /// \param UniqueIdentifier A unique identifier for the union.
  425. DICompositeType *createVariantPart(DIScope *Scope, StringRef Name,
  426. DIFile *File, unsigned LineNumber,
  427. uint64_t SizeInBits, uint32_t AlignInBits,
  428. DINode::DIFlags Flags,
  429. DIDerivedType *Discriminator,
  430. DINodeArray Elements,
  431. StringRef UniqueIdentifier = "");
  432. /// Create debugging information for template
  433. /// type parameter.
  434. /// \param Scope Scope in which this type is defined.
  435. /// \param Name Type parameter name.
  436. /// \param Ty Parameter type.
  437. /// \param IsDefault Parameter is default or not
  438. DITemplateTypeParameter *createTemplateTypeParameter(DIScope *Scope,
  439. StringRef Name,
  440. DIType *Ty,
  441. bool IsDefault);
  442. /// Create debugging information for template
  443. /// value parameter.
  444. /// \param Scope Scope in which this type is defined.
  445. /// \param Name Value parameter name.
  446. /// \param Ty Parameter type.
  447. /// \param IsDefault Parameter is default or not
  448. /// \param Val Constant parameter value.
  449. DITemplateValueParameter *
  450. createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty,
  451. bool IsDefault, Constant *Val);
  452. /// Create debugging information for a template template parameter.
  453. /// \param Scope Scope in which this type is defined.
  454. /// \param Name Value parameter name.
  455. /// \param Ty Parameter type.
  456. /// \param Val The fully qualified name of the template.
  457. DITemplateValueParameter *createTemplateTemplateParameter(DIScope *Scope,
  458. StringRef Name,
  459. DIType *Ty,
  460. StringRef Val);
  461. /// Create debugging information for a template parameter pack.
  462. /// \param Scope Scope in which this type is defined.
  463. /// \param Name Value parameter name.
  464. /// \param Ty Parameter type.
  465. /// \param Val An array of types in the pack.
  466. DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
  467. StringRef Name,
  468. DIType *Ty,
  469. DINodeArray Val);
  470. /// Create debugging information entry for an array.
  471. /// \param Size Array size.
  472. /// \param AlignInBits Alignment.
  473. /// \param Ty Element type.
  474. /// \param Subscripts Subscripts.
  475. /// \param DataLocation The location of the raw data of a descriptor-based
  476. /// Fortran array, either a DIExpression* or
  477. /// a DIVariable*.
  478. /// \param Associated The associated attribute of a descriptor-based
  479. /// Fortran array, either a DIExpression* or
  480. /// a DIVariable*.
  481. /// \param Allocated The allocated attribute of a descriptor-based
  482. /// Fortran array, either a DIExpression* or
  483. /// a DIVariable*.
  484. /// \param Rank The rank attribute of a descriptor-based
  485. /// Fortran array, either a DIExpression* or
  486. /// a DIVariable*.
  487. DICompositeType *createArrayType(
  488. uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts,
  489. PointerUnion<DIExpression *, DIVariable *> DataLocation = nullptr,
  490. PointerUnion<DIExpression *, DIVariable *> Associated = nullptr,
  491. PointerUnion<DIExpression *, DIVariable *> Allocated = nullptr,
  492. PointerUnion<DIExpression *, DIVariable *> Rank = nullptr);
  493. /// Create debugging information entry for a vector type.
  494. /// \param Size Array size.
  495. /// \param AlignInBits Alignment.
  496. /// \param Ty Element type.
  497. /// \param Subscripts Subscripts.
  498. DICompositeType *createVectorType(uint64_t Size, uint32_t AlignInBits,
  499. DIType *Ty, DINodeArray Subscripts);
  500. /// Create debugging information entry for an
  501. /// enumeration.
  502. /// \param Scope Scope in which this enumeration is defined.
  503. /// \param Name Union name.
  504. /// \param File File where this member is defined.
  505. /// \param LineNumber Line number.
  506. /// \param SizeInBits Member size.
  507. /// \param AlignInBits Member alignment.
  508. /// \param Elements Enumeration elements.
  509. /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
  510. /// \param UniqueIdentifier A unique identifier for the enum.
  511. /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum class'.
  512. DICompositeType *createEnumerationType(
  513. DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
  514. uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
  515. DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped = false);
  516. /// Create debugging information entry for a set.
  517. /// \param Scope Scope in which this set is defined.
  518. /// \param Name Set name.
  519. /// \param File File where this set is defined.
  520. /// \param LineNo Line number.
  521. /// \param SizeInBits Set size.
  522. /// \param AlignInBits Set alignment.
  523. /// \param Ty Base type of the set.
  524. DIDerivedType *createSetType(DIScope *Scope, StringRef Name, DIFile *File,
  525. unsigned LineNo, uint64_t SizeInBits,
  526. uint32_t AlignInBits, DIType *Ty);
  527. /// Create subroutine type.
  528. /// \param ParameterTypes An array of subroutine parameter types. This
  529. /// includes return type at 0th index.
  530. /// \param Flags E.g.: LValueReference.
  531. /// These flags are used to emit dwarf attributes.
  532. /// \param CC Calling convention, e.g. dwarf::DW_CC_normal
  533. DISubroutineType *
  534. createSubroutineType(DITypeRefArray ParameterTypes,
  535. DINode::DIFlags Flags = DINode::FlagZero,
  536. unsigned CC = 0);
  537. /// Create a distinct clone of \p SP with FlagArtificial set.
  538. static DISubprogram *createArtificialSubprogram(DISubprogram *SP);
  539. /// Create a uniqued clone of \p Ty with FlagArtificial set.
  540. static DIType *createArtificialType(DIType *Ty);
  541. /// Create a uniqued clone of \p Ty with FlagObjectPointer and
  542. /// FlagArtificial set.
  543. static DIType *createObjectPointerType(DIType *Ty);
  544. /// Create a permanent forward-declared type.
  545. DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
  546. DIScope *Scope, DIFile *F, unsigned Line,
  547. unsigned RuntimeLang = 0,
  548. uint64_t SizeInBits = 0,
  549. uint32_t AlignInBits = 0,
  550. StringRef UniqueIdentifier = "");
  551. /// Create a temporary forward-declared type.
  552. DICompositeType *createReplaceableCompositeType(
  553. unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
  554. unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
  555. uint32_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagFwdDecl,
  556. StringRef UniqueIdentifier = "", DINodeArray Annotations = nullptr);
  557. /// Retain DIScope* in a module even if it is not referenced
  558. /// through debug info anchors.
  559. void retainType(DIScope *T);
  560. /// Create unspecified parameter type
  561. /// for a subroutine type.
  562. DIBasicType *createUnspecifiedParameter();
  563. /// Get a DINodeArray, create one if required.
  564. DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
  565. /// Get a DIMacroNodeArray, create one if required.
  566. DIMacroNodeArray getOrCreateMacroArray(ArrayRef<Metadata *> Elements);
  567. /// Get a DITypeRefArray, create one if required.
  568. DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
  569. /// Create a descriptor for a value range. This
  570. /// implicitly uniques the values returned.
  571. DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
  572. DISubrange *getOrCreateSubrange(int64_t Lo, Metadata *CountNode);
  573. DISubrange *getOrCreateSubrange(Metadata *Count, Metadata *LowerBound,
  574. Metadata *UpperBound, Metadata *Stride);
  575. DIGenericSubrange *
  576. getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count,
  577. DIGenericSubrange::BoundType LowerBound,
  578. DIGenericSubrange::BoundType UpperBound,
  579. DIGenericSubrange::BoundType Stride);
  580. /// Create a new descriptor for the specified variable.
  581. /// \param Context Variable scope.
  582. /// \param Name Name of the variable.
  583. /// \param LinkageName Mangled name of the variable.
  584. /// \param File File where this variable is defined.
  585. /// \param LineNo Line number.
  586. /// \param Ty Variable Type.
  587. /// \param IsLocalToUnit Boolean flag indicate whether this variable is
  588. /// externally visible or not.
  589. /// \param Expr The location of the global relative to the attached
  590. /// GlobalVariable.
  591. /// \param Decl Reference to the corresponding declaration.
  592. /// \param AlignInBits Variable alignment(or 0 if no alignment attr was
  593. /// specified)
  594. DIGlobalVariableExpression *createGlobalVariableExpression(
  595. DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
  596. unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined = true,
  597. DIExpression *Expr = nullptr, MDNode *Decl = nullptr,
  598. MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0,
  599. DINodeArray Annotations = nullptr);
  600. /// Identical to createGlobalVariable
  601. /// except that the resulting DbgNode is temporary and meant to be RAUWed.
  602. DIGlobalVariable *createTempGlobalVariableFwdDecl(
  603. DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
  604. unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl = nullptr,
  605. MDTuple *TemplateParams= nullptr, uint32_t AlignInBits = 0);
  606. /// Create a new descriptor for an auto variable. This is a local variable
  607. /// that is not a subprogram parameter.
  608. ///
  609. /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
  610. /// leads to a \a DISubprogram.
  611. ///
  612. /// If \c AlwaysPreserve, this variable will be referenced from its
  613. /// containing subprogram, and will survive some optimizations.
  614. DILocalVariable *
  615. createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File,
  616. unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false,
  617. DINode::DIFlags Flags = DINode::FlagZero,
  618. uint32_t AlignInBits = 0);
  619. /// Create a new descriptor for an label.
  620. ///
  621. /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
  622. /// leads to a \a DISubprogram.
  623. DILabel *
  624. createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
  625. bool AlwaysPreserve = false);
  626. /// Create a new descriptor for a parameter variable.
  627. ///
  628. /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
  629. /// leads to a \a DISubprogram.
  630. ///
  631. /// \c ArgNo is the index (starting from \c 1) of this variable in the
  632. /// subprogram parameters. \c ArgNo should not conflict with other
  633. /// parameters of the same subprogram.
  634. ///
  635. /// If \c AlwaysPreserve, this variable will be referenced from its
  636. /// containing subprogram, and will survive some optimizations.
  637. DILocalVariable *
  638. createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo,
  639. DIFile *File, unsigned LineNo, DIType *Ty,
  640. bool AlwaysPreserve = false,
  641. DINode::DIFlags Flags = DINode::FlagZero,
  642. DINodeArray Annotations = nullptr);
  643. /// Create a new descriptor for the specified
  644. /// variable which has a complex address expression for its address.
  645. /// \param Addr An array of complex address operations.
  646. DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
  647. /// Create an expression for a variable that does not have an address, but
  648. /// does have a constant value.
  649. DIExpression *createConstantValueExpression(uint64_t Val) {
  650. return DIExpression::get(
  651. VMContext, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_stack_value});
  652. }
  653. /// Create a new descriptor for the specified subprogram.
  654. /// See comments in DISubprogram* for descriptions of these fields.
  655. /// \param Scope Function scope.
  656. /// \param Name Function name.
  657. /// \param LinkageName Mangled function name.
  658. /// \param File File where this variable is defined.
  659. /// \param LineNo Line number.
  660. /// \param Ty Function type.
  661. /// \param ScopeLine Set to the beginning of the scope this starts
  662. /// \param Flags e.g. is this function prototyped or not.
  663. /// These flags are used to emit dwarf attributes.
  664. /// \param SPFlags Additional flags specific to subprograms.
  665. /// \param TParams Function template parameters.
  666. /// \param ThrownTypes Exception types this function may throw.
  667. /// \param Annotations Attribute Annotations.
  668. DISubprogram *
  669. createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
  670. DIFile *File, unsigned LineNo, DISubroutineType *Ty,
  671. unsigned ScopeLine, DINode::DIFlags Flags = DINode::FlagZero,
  672. DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
  673. DITemplateParameterArray TParams = nullptr,
  674. DISubprogram *Decl = nullptr,
  675. DITypeArray ThrownTypes = nullptr,
  676. DINodeArray Annotations = nullptr);
  677. /// Identical to createFunction,
  678. /// except that the resulting DbgNode is meant to be RAUWed.
  679. DISubprogram *createTempFunctionFwdDecl(
  680. DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
  681. unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
  682. DINode::DIFlags Flags = DINode::FlagZero,
  683. DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
  684. DITemplateParameterArray TParams = nullptr,
  685. DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
  686. /// Create a new descriptor for the specified C++ method.
  687. /// See comments in \a DISubprogram* for descriptions of these fields.
  688. /// \param Scope Function scope.
  689. /// \param Name Function name.
  690. /// \param LinkageName Mangled function name.
  691. /// \param File File where this variable is defined.
  692. /// \param LineNo Line number.
  693. /// \param Ty Function type.
  694. /// \param VTableIndex Index no of this method in virtual table, or -1u if
  695. /// unrepresentable.
  696. /// \param ThisAdjustment
  697. /// MS ABI-specific adjustment of 'this' that occurs
  698. /// in the prologue.
  699. /// \param VTableHolder Type that holds vtable.
  700. /// \param Flags e.g. is this function prototyped or not.
  701. /// This flags are used to emit dwarf attributes.
  702. /// \param SPFlags Additional flags specific to subprograms.
  703. /// \param TParams Function template parameters.
  704. /// \param ThrownTypes Exception types this function may throw.
  705. DISubprogram *
  706. createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
  707. DIFile *File, unsigned LineNo, DISubroutineType *Ty,
  708. unsigned VTableIndex = 0, int ThisAdjustment = 0,
  709. DIType *VTableHolder = nullptr,
  710. DINode::DIFlags Flags = DINode::FlagZero,
  711. DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
  712. DITemplateParameterArray TParams = nullptr,
  713. DITypeArray ThrownTypes = nullptr);
  714. /// Create common block entry for a Fortran common block.
  715. /// \param Scope Scope of this common block.
  716. /// \param decl Global variable declaration.
  717. /// \param Name The name of this common block.
  718. /// \param File The file this common block is defined.
  719. /// \param LineNo Line number.
  720. DICommonBlock *createCommonBlock(DIScope *Scope, DIGlobalVariable *decl,
  721. StringRef Name, DIFile *File,
  722. unsigned LineNo);
  723. /// This creates new descriptor for a namespace with the specified
  724. /// parent scope.
  725. /// \param Scope Namespace scope
  726. /// \param Name Name of this namespace
  727. /// \param ExportSymbols True for C++ inline namespaces.
  728. DINamespace *createNameSpace(DIScope *Scope, StringRef Name,
  729. bool ExportSymbols);
  730. /// This creates new descriptor for a module with the specified
  731. /// parent scope.
  732. /// \param Scope Parent scope
  733. /// \param Name Name of this module
  734. /// \param ConfigurationMacros
  735. /// A space-separated shell-quoted list of -D macro
  736. /// definitions as they would appear on a command line.
  737. /// \param IncludePath The path to the module map file.
  738. /// \param APINotesFile The path to an API notes file for this module.
  739. /// \param File Source file of the module.
  740. /// Used for Fortran modules.
  741. /// \param LineNo Source line number of the module.
  742. /// Used for Fortran modules.
  743. /// \param IsDecl This is a module declaration; default to false;
  744. /// when set to true, only Scope and Name are required
  745. /// as this entry is just a hint for the debugger to find
  746. /// the corresponding definition in the global scope.
  747. DIModule *createModule(DIScope *Scope, StringRef Name,
  748. StringRef ConfigurationMacros, StringRef IncludePath,
  749. StringRef APINotesFile = {}, DIFile *File = nullptr,
  750. unsigned LineNo = 0, bool IsDecl = false);
  751. /// This creates a descriptor for a lexical block with a new file
  752. /// attached. This merely extends the existing
  753. /// lexical block as it crosses a file.
  754. /// \param Scope Lexical block.
  755. /// \param File Source file.
  756. /// \param Discriminator DWARF path discriminator value.
  757. DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
  758. unsigned Discriminator = 0);
  759. /// This creates a descriptor for a lexical block with the
  760. /// specified parent context.
  761. /// \param Scope Parent lexical scope.
  762. /// \param File Source file.
  763. /// \param Line Line number.
  764. /// \param Col Column number.
  765. DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
  766. unsigned Line, unsigned Col);
  767. /// Create a descriptor for an imported module.
  768. /// \param Context The scope this module is imported into
  769. /// \param NS The namespace being imported here.
  770. /// \param File File where the declaration is located.
  771. /// \param Line Line number of the declaration.
  772. /// \param Elements Renamed elements.
  773. DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
  774. DIFile *File, unsigned Line,
  775. DINodeArray Elements = nullptr);
  776. /// Create a descriptor for an imported module.
  777. /// \param Context The scope this module is imported into.
  778. /// \param NS An aliased namespace.
  779. /// \param File File where the declaration is located.
  780. /// \param Line Line number of the declaration.
  781. /// \param Elements Renamed elements.
  782. DIImportedEntity *createImportedModule(DIScope *Context,
  783. DIImportedEntity *NS, DIFile *File,
  784. unsigned Line,
  785. DINodeArray Elements = nullptr);
  786. /// Create a descriptor for an imported module.
  787. /// \param Context The scope this module is imported into.
  788. /// \param M The module being imported here
  789. /// \param File File where the declaration is located.
  790. /// \param Line Line number of the declaration.
  791. /// \param Elements Renamed elements.
  792. DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
  793. DIFile *File, unsigned Line,
  794. DINodeArray Elements = nullptr);
  795. /// Create a descriptor for an imported function.
  796. /// \param Context The scope this module is imported into.
  797. /// \param Decl The declaration (or definition) of a function, type, or
  798. /// variable.
  799. /// \param File File where the declaration is located.
  800. /// \param Line Line number of the declaration.
  801. /// \param Elements Renamed elements.
  802. DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
  803. DIFile *File, unsigned Line,
  804. StringRef Name = "",
  805. DINodeArray Elements = nullptr);
  806. /// Insert a new llvm.dbg.declare intrinsic call.
  807. /// \param Storage llvm::Value of the variable
  808. /// \param VarInfo Variable's debug info descriptor.
  809. /// \param Expr A complex location expression.
  810. /// \param DL Debug info location.
  811. /// \param InsertAtEnd Location for the new intrinsic.
  812. Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
  813. DIExpression *Expr, const DILocation *DL,
  814. BasicBlock *InsertAtEnd);
  815. /// Insert a new llvm.dbg.declare intrinsic call.
  816. /// \param Storage llvm::Value of the variable
  817. /// \param VarInfo Variable's debug info descriptor.
  818. /// \param Expr A complex location expression.
  819. /// \param DL Debug info location.
  820. /// \param InsertBefore Location for the new intrinsic.
  821. Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
  822. DIExpression *Expr, const DILocation *DL,
  823. Instruction *InsertBefore);
  824. /// Insert a new llvm.dbg.label intrinsic call.
  825. /// \param LabelInfo Label's debug info descriptor.
  826. /// \param DL Debug info location.
  827. /// \param InsertBefore Location for the new intrinsic.
  828. Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
  829. Instruction *InsertBefore);
  830. /// Insert a new llvm.dbg.label intrinsic call.
  831. /// \param LabelInfo Label's debug info descriptor.
  832. /// \param DL Debug info location.
  833. /// \param InsertAtEnd Location for the new intrinsic.
  834. Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
  835. BasicBlock *InsertAtEnd);
  836. /// Insert a new llvm.dbg.value intrinsic call.
  837. /// \param Val llvm::Value of the variable
  838. /// \param VarInfo Variable's debug info descriptor.
  839. /// \param Expr A complex location expression.
  840. /// \param DL Debug info location.
  841. /// \param InsertAtEnd Location for the new intrinsic.
  842. Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
  843. DILocalVariable *VarInfo,
  844. DIExpression *Expr,
  845. const DILocation *DL,
  846. BasicBlock *InsertAtEnd);
  847. /// Insert a new llvm.dbg.value intrinsic call.
  848. /// \param Val llvm::Value of the variable
  849. /// \param VarInfo Variable's debug info descriptor.
  850. /// \param Expr A complex location expression.
  851. /// \param DL Debug info location.
  852. /// \param InsertBefore Location for the new intrinsic.
  853. Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
  854. DILocalVariable *VarInfo,
  855. DIExpression *Expr,
  856. const DILocation *DL,
  857. Instruction *InsertBefore);
  858. /// Insert a new llvm.dbg.addr intrinsic call.
  859. /// \param Addr llvm::Value of the address
  860. /// \param VarInfo Variable's debug info descriptor.
  861. /// \param Expr A complex location expression.
  862. /// \param DL Debug info location.
  863. /// \param InsertAtEnd Location for the new intrinsic.
  864. Instruction *insertDbgAddrIntrinsic(llvm::Value *Addr,
  865. DILocalVariable *VarInfo,
  866. DIExpression *Expr,
  867. const DILocation *DL,
  868. BasicBlock *InsertAtEnd);
  869. /// Insert a new llvm.dbg.addr intrinsic call.
  870. /// \param Addr llvm::Value of the address.
  871. /// \param VarInfo Variable's debug info descriptor.
  872. /// \param Expr A complex location expression.
  873. /// \param DL Debug info location.
  874. /// \param InsertBefore Location for the new intrinsic.
  875. Instruction *insertDbgAddrIntrinsic(llvm::Value *Addr,
  876. DILocalVariable *VarInfo,
  877. DIExpression *Expr,
  878. const DILocation *DL,
  879. Instruction *InsertBefore);
  880. /// Replace the vtable holder in the given type.
  881. ///
  882. /// If this creates a self reference, it may orphan some unresolved cycles
  883. /// in the operands of \c T, so \a DIBuilder needs to track that.
  884. void replaceVTableHolder(DICompositeType *&T,
  885. DIType *VTableHolder);
  886. /// Replace arrays on a composite type.
  887. ///
  888. /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
  889. /// has a self-reference -- \a DIBuilder needs to track the array to
  890. /// resolve cycles.
  891. void replaceArrays(DICompositeType *&T, DINodeArray Elements,
  892. DINodeArray TParams = DINodeArray());
  893. /// Replace a temporary node.
  894. ///
  895. /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
  896. /// Replacement.
  897. ///
  898. /// If \c Replacement is the same as \c N.get(), instead call \a
  899. /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
  900. /// have a different address, so we return the final address.
  901. template <class NodeTy>
  902. NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
  903. if (N.get() == Replacement)
  904. return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
  905. N->replaceAllUsesWith(Replacement);
  906. return Replacement;
  907. }
  908. };
  909. // Create wrappers for C Binding types (see CBindingWrapping.h).
  910. DEFINE_ISA_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef)
  911. } // end namespace llvm
  912. #endif // LLVM_IR_DIBUILDER_H
  913. #ifdef __GNUC__
  914. #pragma GCC diagnostic pop
  915. #endif