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