1 //===- llvm/IR/DebugInfoMetadata.h - Debug info metadata --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Declarations for metadata specific to debug info.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_IR_DEBUGINFOMETADATA_H
15 #define LLVM_IR_DEBUGINFOMETADATA_H
17 #include "llvm/IR/Metadata.h"
18 #include "llvm/Support/Dwarf.h"
20 // Helper macros for defining get() overrides.
21 #define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__
22 #define DEFINE_MDNODE_GET_UNPACK(ARGS) DEFINE_MDNODE_GET_UNPACK_IMPL ARGS
23 #define DEFINE_MDNODE_GET(CLASS, FORMAL, ARGS) \
24 static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
25 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued); \
27 static CLASS *getIfExists(LLVMContext &Context, \
28 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
29 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued, \
30 /* ShouldCreate */ false); \
32 static CLASS *getDistinct(LLVMContext &Context, \
33 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
34 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct); \
36 static Temp##CLASS getTemporary(LLVMContext &Context, \
37 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
39 getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary)); \
44 /// \brief Tagged DWARF-like metadata node.
46 /// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,
47 /// defined in llvm/Support/Dwarf.h). Called \a DebugNode because it's
48 /// potentially used for non-DWARF output.
49 class DebugNode : public MDNode {
50 friend class LLVMContextImpl;
54 DebugNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
55 ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
56 : MDNode(C, ID, Storage, Ops1, Ops2) {
57 assert(Tag < 1u << 16);
62 template <class Ty> Ty *getOperandAs(unsigned I) const {
63 return cast_or_null<Ty>(getOperand(I));
66 StringRef getStringOperand(unsigned I) const {
67 if (auto *S = getOperandAs<MDString>(I))
68 return S->getString();
72 static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) {
75 return MDString::get(Context, S);
79 unsigned getTag() const { return SubclassData16; }
81 /// \brief Debug info flags.
83 /// The three accessibility flags are mutually exclusive and rolled together
84 /// in the first two bits.
86 #define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = ID,
87 #include "llvm/IR/DebugInfoFlags.def"
88 FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic
91 static bool classof(const Metadata *MD) {
92 switch (MD->getMetadataID()) {
95 case GenericDebugNodeKind:
97 case MDEnumeratorKind:
99 case MDDerivedTypeKind:
100 case MDCompositeTypeKind:
101 case MDSubroutineTypeKind:
103 case MDCompileUnitKind:
104 case MDSubprogramKind:
105 case MDLexicalBlockKind:
106 case MDLexicalBlockFileKind:
107 case MDNamespaceKind:
108 case MDTemplateTypeParameterKind:
109 case MDTemplateValueParameterKind:
110 case MDGlobalVariableKind:
111 case MDLocalVariableKind:
112 case MDObjCPropertyKind:
113 case MDImportedEntityKind:
119 /// \brief Generic tagged DWARF-like metadata node.
121 /// An un-specialized DWARF-like metadata node. The first operand is a
122 /// (possibly empty) null-separated \a MDString header that contains arbitrary
123 /// fields. The remaining operands are \a dwarf_operands(), and are pointers
124 /// to other metadata.
125 class GenericDebugNode : public DebugNode {
126 friend class LLVMContextImpl;
129 GenericDebugNode(LLVMContext &C, StorageType Storage, unsigned Hash,
130 unsigned Tag, ArrayRef<Metadata *> Ops1,
131 ArrayRef<Metadata *> Ops2)
132 : DebugNode(C, GenericDebugNodeKind, Storage, Tag, Ops1, Ops2) {
135 ~GenericDebugNode() { dropAllReferences(); }
137 void setHash(unsigned Hash) { SubclassData32 = Hash; }
138 void recalculateHash();
140 static GenericDebugNode *getImpl(LLVMContext &Context, unsigned Tag,
142 ArrayRef<Metadata *> DwarfOps,
144 bool ShouldCreate = true) {
145 return getImpl(Context, Tag, getCanonicalMDString(Context, Header),
146 DwarfOps, Storage, ShouldCreate);
149 static GenericDebugNode *getImpl(LLVMContext &Context, unsigned Tag,
151 ArrayRef<Metadata *> DwarfOps,
153 bool ShouldCreate = true);
155 TempGenericDebugNode cloneImpl() const {
157 getContext(), getTag(), getHeader(),
158 SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end()));
162 unsigned getHash() const { return SubclassData32; }
164 DEFINE_MDNODE_GET(GenericDebugNode, (unsigned Tag, StringRef Header,
165 ArrayRef<Metadata *> DwarfOps),
166 (Tag, Header, DwarfOps))
167 DEFINE_MDNODE_GET(GenericDebugNode, (unsigned Tag, MDString *Header,
168 ArrayRef<Metadata *> DwarfOps),
169 (Tag, Header, DwarfOps))
171 /// \brief Return a (temporary) clone of this.
172 TempGenericDebugNode clone() const { return cloneImpl(); }
174 unsigned getTag() const { return SubclassData16; }
175 StringRef getHeader() const { return getStringOperand(0); }
177 op_iterator dwarf_op_begin() const { return op_begin() + 1; }
178 op_iterator dwarf_op_end() const { return op_end(); }
179 op_range dwarf_operands() const {
180 return op_range(dwarf_op_begin(), dwarf_op_end());
183 unsigned getNumDwarfOperands() const { return getNumOperands() - 1; }
184 const MDOperand &getDwarfOperand(unsigned I) const {
185 return getOperand(I + 1);
187 void replaceDwarfOperandWith(unsigned I, Metadata *New) {
188 replaceOperandWith(I + 1, New);
191 static bool classof(const Metadata *MD) {
192 return MD->getMetadataID() == GenericDebugNodeKind;
196 /// \brief Array subrange.
198 /// TODO: Merge into node for DW_TAG_array_type, which should have a custom
200 class MDSubrange : public DebugNode {
201 friend class LLVMContextImpl;
207 MDSubrange(LLVMContext &C, StorageType Storage, int64_t Count, int64_t Lo)
208 : DebugNode(C, MDSubrangeKind, Storage, dwarf::DW_TAG_subrange_type,
210 Count(Count), Lo(Lo) {}
213 static MDSubrange *getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
214 StorageType Storage, bool ShouldCreate = true);
216 TempMDSubrange cloneImpl() const {
217 return getTemporary(getContext(), getCount(), getLo());
221 DEFINE_MDNODE_GET(MDSubrange, (int64_t Count, int64_t Lo = 0), (Count, Lo))
223 TempMDSubrange clone() const { return cloneImpl(); }
225 int64_t getLo() const { return Lo; }
226 int64_t getCount() const { return Count; }
228 static bool classof(const Metadata *MD) {
229 return MD->getMetadataID() == MDSubrangeKind;
233 /// \brief Enumeration value.
235 /// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
236 /// longer creates a type cycle.
237 class MDEnumerator : public DebugNode {
238 friend class LLVMContextImpl;
243 MDEnumerator(LLVMContext &C, StorageType Storage, int64_t Value,
244 ArrayRef<Metadata *> Ops)
245 : DebugNode(C, MDEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
249 static MDEnumerator *getImpl(LLVMContext &Context, int64_t Value,
250 StringRef Name, StorageType Storage,
251 bool ShouldCreate = true) {
252 return getImpl(Context, Value, getCanonicalMDString(Context, Name), Storage,
255 static MDEnumerator *getImpl(LLVMContext &Context, int64_t Value,
256 MDString *Name, StorageType Storage,
257 bool ShouldCreate = true);
259 TempMDEnumerator cloneImpl() const {
260 return getTemporary(getContext(), getValue(), getName());
264 DEFINE_MDNODE_GET(MDEnumerator, (int64_t Value, StringRef Name),
266 DEFINE_MDNODE_GET(MDEnumerator, (int64_t Value, MDString *Name),
269 TempMDEnumerator clone() const { return cloneImpl(); }
271 int64_t getValue() const { return Value; }
272 StringRef getName() const { return getStringOperand(0); }
274 MDString *getRawName() const { return getOperandAs<MDString>(0); }
276 static bool classof(const Metadata *MD) {
277 return MD->getMetadataID() == MDEnumeratorKind;
281 /// \brief Base class for scope-like contexts.
283 /// Base class for lexical scopes and types (which are also declaration
286 /// TODO: Separate the concepts of declaration contexts and lexical scopes.
287 class MDScope : public DebugNode {
289 MDScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
290 ArrayRef<Metadata *> Ops)
291 : DebugNode(C, ID, Storage, Tag, Ops) {}
295 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
297 /// \brief Return the raw underlying file.
299 /// An \a MDFile is an \a MDScope, but it doesn't point at a separate file
300 /// (it\em is the file). If \c this is an \a MDFile, we need to return \c
301 /// this. Otherwise, return the first operand, which is where all other
302 /// subclasses store their file pointer.
303 Metadata *getRawFile() const {
304 return isa<MDFile>(this) ? const_cast<MDScope *>(this)
305 : static_cast<Metadata *>(getOperand(0));
308 static bool classof(const Metadata *MD) {
309 switch (MD->getMetadataID()) {
312 case MDBasicTypeKind:
313 case MDDerivedTypeKind:
314 case MDCompositeTypeKind:
315 case MDSubroutineTypeKind:
317 case MDCompileUnitKind:
318 case MDSubprogramKind:
319 case MDLexicalBlockKind:
320 case MDLexicalBlockFileKind:
321 case MDNamespaceKind:
329 /// TODO: Merge with directory/file node (including users).
330 /// TODO: Canonicalize paths on creation.
331 class MDFile : public MDScope {
332 friend class LLVMContextImpl;
335 MDFile(LLVMContext &C, StorageType Storage, ArrayRef<Metadata *> Ops)
336 : MDScope(C, MDFileKind, Storage, dwarf::DW_TAG_file_type, Ops) {}
339 static MDFile *getImpl(LLVMContext &Context, StringRef Filename,
340 StringRef Directory, StorageType Storage,
341 bool ShouldCreate = true) {
342 return getImpl(Context, getCanonicalMDString(Context, Filename),
343 getCanonicalMDString(Context, Directory), Storage,
346 static MDFile *getImpl(LLVMContext &Context, MDString *Filename,
347 MDString *Directory, StorageType Storage,
348 bool ShouldCreate = true);
350 TempMDFile cloneImpl() const {
351 return getTemporary(getContext(), getFilename(), getDirectory());
355 DEFINE_MDNODE_GET(MDFile, (StringRef Filename, StringRef Directory),
356 (Filename, Directory))
357 DEFINE_MDNODE_GET(MDFile, (MDString * Filename, MDString *Directory),
358 (Filename, Directory))
360 TempMDFile clone() const { return cloneImpl(); }
362 StringRef getFilename() const { return getStringOperand(0); }
363 StringRef getDirectory() const { return getStringOperand(1); }
365 MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
366 MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
368 static bool classof(const Metadata *MD) {
369 return MD->getMetadataID() == MDFileKind;
373 /// \brief Base class for types.
375 /// TODO: Remove the hardcoded name and context, since many types don't use
377 /// TODO: Split up flags.
378 class MDType : public MDScope {
382 uint64_t AlignInBits;
383 uint64_t OffsetInBits;
386 MDType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
387 unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
388 uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
389 : MDScope(C, ID, Storage, Tag, Ops), Line(Line), Flags(Flags),
390 SizeInBits(SizeInBits), AlignInBits(AlignInBits),
391 OffsetInBits(OffsetInBits) {}
395 TempMDType clone() const {
396 return TempMDType(cast<MDType>(MDNode::clone().release()));
399 unsigned getLine() const { return Line; }
400 uint64_t getSizeInBits() const { return SizeInBits; }
401 uint64_t getAlignInBits() const { return AlignInBits; }
402 uint64_t getOffsetInBits() const { return OffsetInBits; }
403 unsigned getFlags() const { return Flags; }
405 Metadata *getScope() const { return getRawScope(); }
406 StringRef getName() const { return getStringOperand(2); }
409 Metadata *getRawScope() const { return getOperand(1); }
410 MDString *getRawName() const { return getOperandAs<MDString>(2); }
412 void setFlags(unsigned NewFlags) {
413 assert(!isUniqued() && "Cannot set flags on uniqued nodes");
417 static bool classof(const Metadata *MD) {
418 switch (MD->getMetadataID()) {
421 case MDBasicTypeKind:
422 case MDDerivedTypeKind:
423 case MDCompositeTypeKind:
424 case MDSubroutineTypeKind:
430 /// \brief Basic type.
432 /// TODO: Split out DW_TAG_unspecified_type.
433 /// TODO: Drop unused accessors.
434 class MDBasicType : public MDType {
435 friend class LLVMContextImpl;
440 MDBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
441 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Encoding,
442 ArrayRef<Metadata *> Ops)
443 : MDType(C, MDBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
445 Encoding(Encoding) {}
448 static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
449 StringRef Name, uint64_t SizeInBits,
450 uint64_t AlignInBits, unsigned Encoding,
451 StorageType Storage, bool ShouldCreate = true) {
452 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
453 SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate);
455 static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
456 MDString *Name, uint64_t SizeInBits,
457 uint64_t AlignInBits, unsigned Encoding,
458 StorageType Storage, bool ShouldCreate = true);
460 TempMDBasicType cloneImpl() const {
461 return getTemporary(getContext(), getTag(), getName(), getSizeInBits(),
462 getAlignInBits(), getEncoding());
466 DEFINE_MDNODE_GET(MDBasicType, (unsigned Tag, StringRef Name),
467 (Tag, Name, 0, 0, 0))
468 DEFINE_MDNODE_GET(MDBasicType,
469 (unsigned Tag, StringRef Name, uint64_t SizeInBits,
470 uint64_t AlignInBits, unsigned Encoding),
471 (Tag, Name, SizeInBits, AlignInBits, Encoding))
472 DEFINE_MDNODE_GET(MDBasicType,
473 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
474 uint64_t AlignInBits, unsigned Encoding),
475 (Tag, Name, SizeInBits, AlignInBits, Encoding))
477 TempMDBasicType clone() const { return cloneImpl(); }
479 unsigned getEncoding() const { return Encoding; }
481 static bool classof(const Metadata *MD) {
482 return MD->getMetadataID() == MDBasicTypeKind;
486 /// \brief Base class for MDDerivedType and MDCompositeType.
488 /// TODO: Delete; they're not really related.
489 class MDDerivedTypeBase : public MDType {
491 MDDerivedTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
492 unsigned Tag, unsigned Line, uint64_t SizeInBits,
493 uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
494 ArrayRef<Metadata *> Ops)
495 : MDType(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
497 ~MDDerivedTypeBase() {}
500 Metadata *getBaseType() const { return getRawBaseType(); }
501 Metadata *getRawBaseType() const { return getOperand(3); }
503 static bool classof(const Metadata *MD) {
504 return MD->getMetadataID() == MDDerivedTypeKind ||
505 MD->getMetadataID() == MDCompositeTypeKind ||
506 MD->getMetadataID() == MDSubroutineTypeKind;
510 /// \brief Derived types.
512 /// This includes qualified types, pointers, references, friends, typedefs, and
515 /// TODO: Split out members (inheritance, fields, methods, etc.).
516 class MDDerivedType : public MDDerivedTypeBase {
517 friend class LLVMContextImpl;
520 MDDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
521 unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
522 uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
523 : MDDerivedTypeBase(C, MDDerivedTypeKind, Storage, Tag, Line, SizeInBits,
524 AlignInBits, OffsetInBits, Flags, Ops) {}
527 static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
528 StringRef Name, MDFile *File, unsigned Line,
529 Metadata *Scope, Metadata *BaseType,
530 uint64_t SizeInBits, uint64_t AlignInBits,
531 uint64_t OffsetInBits, unsigned Flags,
532 Metadata *ExtraData, StorageType Storage,
533 bool ShouldCreate = true) {
534 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
535 Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
536 Flags, ExtraData, Storage, ShouldCreate);
538 static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
539 MDString *Name, Metadata *File, unsigned Line,
540 Metadata *Scope, Metadata *BaseType,
541 uint64_t SizeInBits, uint64_t AlignInBits,
542 uint64_t OffsetInBits, unsigned Flags,
543 Metadata *ExtraData, StorageType Storage,
544 bool ShouldCreate = true);
546 TempMDDerivedType cloneImpl() const {
547 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
548 getScope(), getBaseType(), getSizeInBits(),
549 getAlignInBits(), getOffsetInBits(), getFlags(),
554 DEFINE_MDNODE_GET(MDDerivedType,
555 (unsigned Tag, MDString *Name, Metadata *File,
556 unsigned Line, Metadata *Scope, Metadata *BaseType,
557 uint64_t SizeInBits, uint64_t AlignInBits,
558 uint64_t OffsetInBits, unsigned Flags,
559 Metadata *ExtraData = nullptr),
560 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
561 AlignInBits, OffsetInBits, Flags, ExtraData))
562 DEFINE_MDNODE_GET(MDDerivedType,
563 (unsigned Tag, StringRef Name, MDFile *File,
564 unsigned Line, Metadata *Scope, Metadata *BaseType,
565 uint64_t SizeInBits, uint64_t AlignInBits,
566 uint64_t OffsetInBits, unsigned Flags,
567 Metadata *ExtraData = nullptr),
568 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
569 AlignInBits, OffsetInBits, Flags, ExtraData))
571 TempMDDerivedType clone() const { return cloneImpl(); }
573 /// \brief Get extra data associated with this derived type.
575 /// Class type for pointer-to-members, objective-c property node for ivars,
576 /// or global constant wrapper for static members.
578 /// TODO: Separate out types that need this extra operand: pointer-to-member
579 /// types and member fields (static members and ivars).
580 Metadata *getExtraData() const { return getRawExtraData(); }
581 Metadata *getRawExtraData() const { return getOperand(4); }
583 static bool classof(const Metadata *MD) {
584 return MD->getMetadataID() == MDDerivedTypeKind;
588 /// \brief Base class for MDCompositeType and MDSubroutineType.
590 /// TODO: Delete; they're not really related.
591 class MDCompositeTypeBase : public MDDerivedTypeBase {
592 unsigned RuntimeLang;
595 MDCompositeTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
596 unsigned Tag, unsigned Line, unsigned RuntimeLang,
597 uint64_t SizeInBits, uint64_t AlignInBits,
598 uint64_t OffsetInBits, unsigned Flags,
599 ArrayRef<Metadata *> Ops)
600 : MDDerivedTypeBase(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits,
601 OffsetInBits, Flags, Ops),
602 RuntimeLang(RuntimeLang) {}
603 ~MDCompositeTypeBase() {}
606 MDTuple *getElements() const {
607 return cast_or_null<MDTuple>(getRawElements());
609 Metadata *getVTableHolder() const { return getRawVTableHolder(); }
610 MDTuple *getTemplateParams() const {
611 return cast_or_null<MDTuple>(getRawTemplateParams());
613 StringRef getIdentifier() const { return getStringOperand(7); }
614 unsigned getRuntimeLang() const { return RuntimeLang; }
616 Metadata *getRawElements() const { return getOperand(4); }
617 Metadata *getRawVTableHolder() const { return getOperand(5); }
618 Metadata *getRawTemplateParams() const { return getOperand(6); }
619 MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
621 /// \brief Replace operands.
623 /// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
624 /// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
625 /// of its movement if necessary.
627 void replaceElements(MDTuple *Elements) {
629 if (auto *Old = cast_or_null<MDTuple>(getElements()))
630 for (const auto &Op : Old->operands())
631 assert(std::find(Elements->op_begin(), Elements->op_end(), Op) &&
632 "Lost a member during member list replacement");
634 replaceOperandWith(4, Elements);
636 void replaceVTableHolder(Metadata *VTableHolder) {
637 replaceOperandWith(5, VTableHolder);
639 void replaceTemplateParams(MDTuple *TemplateParams) {
640 replaceOperandWith(6, TemplateParams);
644 static bool classof(const Metadata *MD) {
645 return MD->getMetadataID() == MDCompositeTypeKind ||
646 MD->getMetadataID() == MDSubroutineTypeKind;
650 /// \brief Composite types.
652 /// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
653 /// TODO: Create a custom, unrelated node for DW_TAG_array_type.
654 class MDCompositeType : public MDCompositeTypeBase {
655 friend class LLVMContextImpl;
658 MDCompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
659 unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
660 uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
661 ArrayRef<Metadata *> Ops)
662 : MDCompositeTypeBase(C, MDCompositeTypeKind, Storage, Tag, Line,
663 RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
665 ~MDCompositeType() {}
667 static MDCompositeType *
668 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
669 unsigned Line, Metadata *Scope, Metadata *BaseType,
670 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
671 uint64_t Flags, Metadata *Elements, unsigned RuntimeLang,
672 Metadata *VTableHolder, Metadata *TemplateParams,
673 StringRef Identifier, StorageType Storage, bool ShouldCreate = true) {
674 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
675 Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
676 Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
677 getCanonicalMDString(Context, Identifier), Storage,
680 static MDCompositeType *
681 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
682 unsigned Line, Metadata *Scope, Metadata *BaseType,
683 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
684 unsigned Flags, Metadata *Elements, unsigned RuntimeLang,
685 Metadata *VTableHolder, Metadata *TemplateParams,
686 MDString *Identifier, StorageType Storage, bool ShouldCreate = true);
688 TempMDCompositeType cloneImpl() const {
689 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
690 getScope(), getBaseType(), getSizeInBits(),
691 getAlignInBits(), getOffsetInBits(), getFlags(),
692 getElements(), getRuntimeLang(), getVTableHolder(),
693 getTemplateParams(), getIdentifier());
697 DEFINE_MDNODE_GET(MDCompositeType,
698 (unsigned Tag, StringRef Name, Metadata *File,
699 unsigned Line, Metadata *Scope, Metadata *BaseType,
700 uint64_t SizeInBits, uint64_t AlignInBits,
701 uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
702 unsigned RuntimeLang, Metadata *VTableHolder,
703 Metadata *TemplateParams = nullptr,
704 StringRef Identifier = ""),
705 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
706 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
707 VTableHolder, TemplateParams, Identifier))
708 DEFINE_MDNODE_GET(MDCompositeType,
709 (unsigned Tag, MDString *Name, Metadata *File,
710 unsigned Line, Metadata *Scope, Metadata *BaseType,
711 uint64_t SizeInBits, uint64_t AlignInBits,
712 uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
713 unsigned RuntimeLang, Metadata *VTableHolder,
714 Metadata *TemplateParams = nullptr,
715 MDString *Identifier = nullptr),
716 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
717 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
718 VTableHolder, TemplateParams, Identifier))
720 TempMDCompositeType clone() const { return cloneImpl(); }
722 static bool classof(const Metadata *MD) {
723 return MD->getMetadataID() == MDCompositeTypeKind;
727 /// \brief Type array for a subprogram.
729 /// TODO: Detach from CompositeType, and fold the array of types in directly
731 class MDSubroutineType : public MDCompositeTypeBase {
732 friend class LLVMContextImpl;
735 MDSubroutineType(LLVMContext &C, StorageType Storage, unsigned Flags,
736 ArrayRef<Metadata *> Ops)
737 : MDCompositeTypeBase(C, MDSubroutineTypeKind, Storage,
738 dwarf::DW_TAG_subroutine_type, 0, 0, 0, 0, 0, Flags,
740 ~MDSubroutineType() {}
742 static MDSubroutineType *getImpl(LLVMContext &Context, unsigned Flags,
743 Metadata *TypeArray, StorageType Storage,
744 bool ShouldCreate = true);
746 TempMDSubroutineType cloneImpl() const {
747 return getTemporary(getContext(), getFlags(), getTypeArray());
751 DEFINE_MDNODE_GET(MDSubroutineType, (unsigned Flags, Metadata *TypeArray),
754 TempMDSubroutineType clone() const { return cloneImpl(); }
756 MDTuple *getTypeArray() const { return getElements(); }
757 Metadata *getRawTypeArray() const { return getRawElements(); }
759 static bool classof(const Metadata *MD) {
760 return MD->getMetadataID() == MDSubroutineTypeKind;
764 /// \brief Compile unit.
765 class MDCompileUnit : public MDScope {
766 friend class LLVMContextImpl;
769 unsigned SourceLanguage;
771 unsigned RuntimeVersion;
772 unsigned EmissionKind;
774 MDCompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
775 bool IsOptimized, unsigned RuntimeVersion,
776 unsigned EmissionKind, ArrayRef<Metadata *> Ops)
777 : MDScope(C, MDCompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
778 SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
779 RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind) {}
782 static MDCompileUnit *
783 getImpl(LLVMContext &Context, unsigned SourceLanguage, MDFile *File,
784 StringRef Producer, bool IsOptimized, StringRef Flags,
785 unsigned RuntimeVersion, StringRef SplitDebugFilename,
786 unsigned EmissionKind, MDTuple *EnumTypes, MDTuple *RetainedTypes,
787 MDTuple *Subprograms, MDTuple *GlobalVariables,
788 MDTuple *ImportedEntities, StorageType Storage,
789 bool ShouldCreate = true) {
790 return getImpl(Context, SourceLanguage, File,
791 getCanonicalMDString(Context, Producer), IsOptimized,
792 getCanonicalMDString(Context, Flags), RuntimeVersion,
793 getCanonicalMDString(Context, SplitDebugFilename),
794 EmissionKind, EnumTypes, RetainedTypes, Subprograms,
795 GlobalVariables, ImportedEntities, Storage, ShouldCreate);
797 static MDCompileUnit *
798 getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
799 MDString *Producer, bool IsOptimized, MDString *Flags,
800 unsigned RuntimeVersion, MDString *SplitDebugFilename,
801 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
802 Metadata *Subprograms, Metadata *GlobalVariables,
803 Metadata *ImportedEntities, StorageType Storage,
804 bool ShouldCreate = true);
806 TempMDCompileUnit cloneImpl() const {
808 getContext(), getSourceLanguage(), getFile(), getProducer(),
809 isOptimized(), getFlags(), getRuntimeVersion(), getSplitDebugFilename(),
810 getEmissionKind(), getEnumTypes(), getRetainedTypes(), getSubprograms(),
811 getGlobalVariables(), getImportedEntities());
815 DEFINE_MDNODE_GET(MDCompileUnit,
816 (unsigned SourceLanguage, MDFile *File, StringRef Producer,
817 bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
818 StringRef SplitDebugFilename, unsigned EmissionKind,
819 MDTuple *EnumTypes, MDTuple *RetainedTypes,
820 MDTuple *Subprograms, MDTuple *GlobalVariables,
821 MDTuple *ImportedEntities),
822 (SourceLanguage, File, Producer, IsOptimized, Flags,
823 RuntimeVersion, SplitDebugFilename, EmissionKind,
824 EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
826 DEFINE_MDNODE_GET(MDCompileUnit,
827 (unsigned SourceLanguage, Metadata *File,
828 MDString *Producer, bool IsOptimized, MDString *Flags,
829 unsigned RuntimeVersion, MDString *SplitDebugFilename,
830 unsigned EmissionKind, Metadata *EnumTypes,
831 Metadata *RetainedTypes, Metadata *Subprograms,
832 Metadata *GlobalVariables, Metadata *ImportedEntities),
833 (SourceLanguage, File, Producer, IsOptimized, Flags,
834 RuntimeVersion, SplitDebugFilename, EmissionKind,
835 EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
838 TempMDCompileUnit clone() const { return cloneImpl(); }
840 unsigned getSourceLanguage() const { return SourceLanguage; }
841 bool isOptimized() const { return IsOptimized; }
842 unsigned getRuntimeVersion() const { return RuntimeVersion; }
843 unsigned getEmissionKind() const { return EmissionKind; }
844 StringRef getProducer() const { return getStringOperand(1); }
845 StringRef getFlags() const { return getStringOperand(2); }
846 StringRef getSplitDebugFilename() const { return getStringOperand(3); }
847 MDTuple *getEnumTypes() const {
848 return cast_or_null<MDTuple>(getRawEnumTypes());
850 MDTuple *getRetainedTypes() const {
851 return cast_or_null<MDTuple>(getRawRetainedTypes());
853 MDTuple *getSubprograms() const {
854 return cast_or_null<MDTuple>(getRawSubprograms());
856 MDTuple *getGlobalVariables() const {
857 return cast_or_null<MDTuple>(getRawGlobalVariables());
859 MDTuple *getImportedEntities() const {
860 return cast_or_null<MDTuple>(getRawImportedEntities());
863 MDString *getRawProducer() const { return getOperandAs<MDString>(1); }
864 MDString *getRawFlags() const { return getOperandAs<MDString>(2); }
865 MDString *getRawSplitDebugFilename() const {
866 return getOperandAs<MDString>(3);
868 Metadata *getRawEnumTypes() const { return getOperand(4); }
869 Metadata *getRawRetainedTypes() const { return getOperand(5); }
870 Metadata *getRawSubprograms() const { return getOperand(6); }
871 Metadata *getRawGlobalVariables() const { return getOperand(7); }
872 Metadata *getRawImportedEntities() const { return getOperand(8); }
874 /// \brief Replace arrays.
876 /// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
877 /// deleted on a uniquing collision. In practice, uniquing collisions on \a
878 /// MDCompileUnit should be fairly rare.
880 void replaceSubprograms(MDTuple *N) { replaceOperandWith(6, N); }
881 void replaceGlobalVariables(MDTuple *N) { replaceOperandWith(7, N); }
884 static bool classof(const Metadata *MD) {
885 return MD->getMetadataID() == MDCompileUnitKind;
889 /// \brief A scope for locals.
891 /// A legal scope for lexical blocks, local variables, and debug info
892 /// locations. Subclasses are \a MDSubprogram, \a MDLexicalBlock, and \a
893 /// MDLexicalBlockFile.
894 class MDLocalScope : public MDScope {
896 MDLocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
897 ArrayRef<Metadata *> Ops)
898 : MDScope(C, ID, Storage, Tag, Ops) {}
902 /// \brief Get the subprogram for this scope.
904 /// Return this if it's an \a MDSubprogram; otherwise, look up the scope
906 MDSubprogram *getSubprogram() const;
908 static bool classof(const Metadata *MD) {
909 return MD->getMetadataID() == MDSubprogramKind ||
910 MD->getMetadataID() == MDLexicalBlockKind ||
911 MD->getMetadataID() == MDLexicalBlockFileKind;
915 /// \brief Debug location.
917 /// A debug location in source code, used for debug info and otherwise.
918 class MDLocation : public MDNode {
919 friend class LLVMContextImpl;
922 MDLocation(LLVMContext &C, StorageType Storage, unsigned Line,
923 unsigned Column, ArrayRef<Metadata *> MDs);
924 ~MDLocation() { dropAllReferences(); }
926 static MDLocation *getImpl(LLVMContext &Context, unsigned Line,
927 unsigned Column, Metadata *Scope,
928 Metadata *InlinedAt, StorageType Storage,
929 bool ShouldCreate = true);
930 static MDLocation *getImpl(LLVMContext &Context, unsigned Line,
931 unsigned Column, MDLocalScope *Scope,
932 MDLocation *InlinedAt, StorageType Storage,
933 bool ShouldCreate = true) {
934 return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
935 static_cast<Metadata *>(InlinedAt), Storage, ShouldCreate);
938 TempMDLocation cloneImpl() const {
939 return getTemporary(getContext(), getLine(), getColumn(), getScope(),
943 // Disallow replacing operands.
944 void replaceOperandWith(unsigned I, Metadata *New) = delete;
947 DEFINE_MDNODE_GET(MDLocation,
948 (unsigned Line, unsigned Column, Metadata *Scope,
949 Metadata *InlinedAt = nullptr),
950 (Line, Column, Scope, InlinedAt))
951 DEFINE_MDNODE_GET(MDLocation,
952 (unsigned Line, unsigned Column, MDLocalScope *Scope,
953 MDLocation *InlinedAt = nullptr),
954 (Line, Column, Scope, InlinedAt))
956 /// \brief Return a (temporary) clone of this.
957 TempMDLocation clone() const { return cloneImpl(); }
959 unsigned getLine() const { return SubclassData32; }
960 unsigned getColumn() const { return SubclassData16; }
961 MDLocalScope *getScope() const {
962 return cast_or_null<MDLocalScope>(getRawScope());
964 MDLocation *getInlinedAt() const {
965 return cast_or_null<MDLocation>(getRawInlinedAt());
968 /// \brief Get the scope where this is inlined.
970 /// Walk through \a getInlinedAt() and return \a getScope() from the deepest
972 MDLocalScope *getInlinedAtScope() const {
973 if (auto *IA = getInlinedAt())
974 return IA->getInlinedAtScope();
978 Metadata *getRawScope() const { return getOperand(0); }
979 Metadata *getRawInlinedAt() const {
980 if (getNumOperands() == 2)
981 return getOperand(1);
985 static bool classof(const Metadata *MD) {
986 return MD->getMetadataID() == MDLocationKind;
990 /// \brief Subprogram description.
992 /// TODO: Remove DisplayName. It's always equal to Name.
993 /// TODO: Split up flags.
994 class MDSubprogram : public MDLocalScope {
995 friend class LLVMContextImpl;
1000 unsigned Virtuality;
1001 unsigned VirtualIndex;
1007 MDSubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
1008 unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
1009 unsigned Flags, bool IsLocalToUnit, bool IsDefinition,
1010 bool IsOptimized, ArrayRef<Metadata *> Ops)
1011 : MDLocalScope(C, MDSubprogramKind, Storage, dwarf::DW_TAG_subprogram,
1013 Line(Line), ScopeLine(ScopeLine), Virtuality(Virtuality),
1014 VirtualIndex(VirtualIndex), Flags(Flags), IsLocalToUnit(IsLocalToUnit),
1015 IsDefinition(IsDefinition), IsOptimized(IsOptimized) {}
1018 static MDSubprogram *
1019 getImpl(LLVMContext &Context, Metadata *Scope, StringRef Name,
1020 StringRef LinkageName, MDFile *File, unsigned Line,
1021 MDSubroutineType *Type, bool IsLocalToUnit, bool IsDefinition,
1022 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
1023 unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
1024 ConstantAsMetadata *Function, MDTuple *TemplateParams,
1025 MDSubprogram *Declaration, MDTuple *Variables, StorageType Storage,
1026 bool ShouldCreate = true) {
1027 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1028 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1029 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1030 Virtuality, VirtualIndex, Flags, IsOptimized, Function,
1031 TemplateParams, Declaration, Variables, Storage,
1034 static MDSubprogram *
1035 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1036 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1037 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
1038 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
1039 unsigned Flags, bool IsOptimized, Metadata *Function,
1040 Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
1041 StorageType Storage, bool ShouldCreate = true);
1043 TempMDSubprogram cloneImpl() const {
1044 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1045 getFile(), getLine(), getType(), isLocalToUnit(),
1046 isDefinition(), getScopeLine(), getContainingType(),
1047 getVirtuality(), getVirtualIndex(), getFlags(),
1048 isOptimized(), getFunction(), getTemplateParams(),
1049 getDeclaration(), getVariables());
1055 (Metadata * Scope, StringRef Name, StringRef LinkageName, MDFile *File,
1056 unsigned Line, MDSubroutineType *Type, bool IsLocalToUnit,
1057 bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType,
1058 unsigned Virtuality, unsigned VirtualIndex, unsigned Flags,
1059 bool IsOptimized, ConstantAsMetadata *Function = nullptr,
1060 MDTuple *TemplateParams = nullptr, MDSubprogram *Declaration = nullptr,
1061 MDTuple *Variables = nullptr),
1062 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1063 ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized,
1064 Function, TemplateParams, Declaration, Variables))
1067 (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
1068 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
1069 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
1070 unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
1071 Metadata *Function = nullptr, Metadata *TemplateParams = nullptr,
1072 Metadata *Declaration = nullptr, Metadata *Variables = nullptr),
1073 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1074 ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized,
1075 Function, TemplateParams, Declaration, Variables))
1077 TempMDSubprogram clone() const { return cloneImpl(); }
1080 unsigned getLine() const { return Line; }
1081 unsigned getVirtuality() const { return Virtuality; }
1082 unsigned getVirtualIndex() const { return VirtualIndex; }
1083 unsigned getScopeLine() const { return ScopeLine; }
1084 unsigned getFlags() const { return Flags; }
1085 bool isLocalToUnit() const { return IsLocalToUnit; }
1086 bool isDefinition() const { return IsDefinition; }
1087 bool isOptimized() const { return IsOptimized; }
1089 Metadata *getScope() const { return getRawScope(); }
1091 StringRef getName() const { return getStringOperand(2); }
1092 StringRef getDisplayName() const { return getStringOperand(3); }
1093 StringRef getLinkageName() const { return getStringOperand(4); }
1095 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1096 MDString *getRawLinkageName() const { return getOperandAs<MDString>(4); }
1098 MDSubroutineType *getType() const {
1099 return cast_or_null<MDSubroutineType>(getRawType());
1101 Metadata *getContainingType() const { return getRawContainingType(); }
1103 ConstantAsMetadata *getFunction() const {
1104 return cast_or_null<ConstantAsMetadata>(getRawFunction());
1106 MDTuple *getTemplateParams() const {
1107 return cast_or_null<MDTuple>(getRawTemplateParams());
1109 MDSubprogram *getDeclaration() const {
1110 return cast_or_null<MDSubprogram>(getRawDeclaration());
1112 MDTuple *getVariables() const {
1113 return cast_or_null<MDTuple>(getRawVariables());
1116 Metadata *getRawScope() const { return getOperand(1); }
1117 Metadata *getRawType() const { return getOperand(5); }
1118 Metadata *getRawContainingType() const { return getOperand(6); }
1119 Metadata *getRawFunction() const { return getOperand(7); }
1120 Metadata *getRawTemplateParams() const { return getOperand(8); }
1121 Metadata *getRawDeclaration() const { return getOperand(9); }
1122 Metadata *getRawVariables() const { return getOperand(10); }
1124 /// \brief Replace the function.
1126 /// If \a isUniqued() and not \a isResolved(), this could node will be
1127 /// RAUW'ed and deleted out from under the caller. Use a \a TrackingMDRef if
1128 /// that's a problem.
1130 void replaceFunction(Function *F);
1131 void replaceFunction(ConstantAsMetadata *MD) { replaceOperandWith(7, MD); }
1132 void replaceFunction(std::nullptr_t) { replaceOperandWith(7, nullptr); }
1135 static bool classof(const Metadata *MD) {
1136 return MD->getMetadataID() == MDSubprogramKind;
1140 class MDLexicalBlockBase : public MDLocalScope {
1142 MDLexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage,
1143 ArrayRef<Metadata *> Ops)
1144 : MDLocalScope(C, ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
1145 ~MDLexicalBlockBase() {}
1148 MDLocalScope *getScope() const { return cast<MDLocalScope>(getRawScope()); }
1150 Metadata *getRawScope() const { return getOperand(1); }
1152 static bool classof(const Metadata *MD) {
1153 return MD->getMetadataID() == MDLexicalBlockKind ||
1154 MD->getMetadataID() == MDLexicalBlockFileKind;
1158 class MDLexicalBlock : public MDLexicalBlockBase {
1159 friend class LLVMContextImpl;
1160 friend class MDNode;
1165 MDLexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
1166 unsigned Column, ArrayRef<Metadata *> Ops)
1167 : MDLexicalBlockBase(C, MDLexicalBlockKind, Storage, Ops), Line(Line),
1169 ~MDLexicalBlock() {}
1171 static MDLexicalBlock *getImpl(LLVMContext &Context, MDLocalScope *Scope,
1172 MDFile *File, unsigned Line, unsigned Column,
1173 StorageType Storage,
1174 bool ShouldCreate = true) {
1175 return getImpl(Context, static_cast<Metadata *>(Scope),
1176 static_cast<Metadata *>(File), Line, Column, Storage,
1180 static MDLexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
1181 Metadata *File, unsigned Line, unsigned Column,
1182 StorageType Storage, bool ShouldCreate = true);
1184 TempMDLexicalBlock cloneImpl() const {
1185 return getTemporary(getContext(), getScope(), getFile(), getLine(),
1190 DEFINE_MDNODE_GET(MDLexicalBlock, (MDLocalScope * Scope, MDFile *File,
1191 unsigned Line, unsigned Column),
1192 (Scope, File, Line, Column))
1193 DEFINE_MDNODE_GET(MDLexicalBlock, (Metadata * Scope, Metadata *File,
1194 unsigned Line, unsigned Column),
1195 (Scope, File, Line, Column))
1197 TempMDLexicalBlock clone() const { return cloneImpl(); }
1199 unsigned getLine() const { return Line; }
1200 unsigned getColumn() const { return Column; }
1202 static bool classof(const Metadata *MD) {
1203 return MD->getMetadataID() == MDLexicalBlockKind;
1207 class MDLexicalBlockFile : public MDLexicalBlockBase {
1208 friend class LLVMContextImpl;
1209 friend class MDNode;
1211 unsigned Discriminator;
1213 MDLexicalBlockFile(LLVMContext &C, StorageType Storage,
1214 unsigned Discriminator, ArrayRef<Metadata *> Ops)
1215 : MDLexicalBlockBase(C, MDLexicalBlockFileKind, Storage, Ops),
1216 Discriminator(Discriminator) {}
1217 ~MDLexicalBlockFile() {}
1219 static MDLexicalBlockFile *getImpl(LLVMContext &Context, MDLocalScope *Scope,
1220 MDFile *File, unsigned Discriminator,
1221 StorageType Storage,
1222 bool ShouldCreate = true) {
1223 return getImpl(Context, static_cast<Metadata *>(Scope),
1224 static_cast<Metadata *>(File), Discriminator, Storage,
1228 static MDLexicalBlockFile *getImpl(LLVMContext &Context, Metadata *Scope,
1229 Metadata *File, unsigned Discriminator,
1230 StorageType Storage,
1231 bool ShouldCreate = true);
1233 TempMDLexicalBlockFile cloneImpl() const {
1234 return getTemporary(getContext(), getScope(), getFile(),
1235 getDiscriminator());
1239 DEFINE_MDNODE_GET(MDLexicalBlockFile, (MDLocalScope * Scope, MDFile *File,
1240 unsigned Discriminator),
1241 (Scope, File, Discriminator))
1242 DEFINE_MDNODE_GET(MDLexicalBlockFile,
1243 (Metadata * Scope, Metadata *File, unsigned Discriminator),
1244 (Scope, File, Discriminator))
1246 TempMDLexicalBlockFile clone() const { return cloneImpl(); }
1248 unsigned getDiscriminator() const { return Discriminator; }
1250 static bool classof(const Metadata *MD) {
1251 return MD->getMetadataID() == MDLexicalBlockFileKind;
1255 class MDNamespace : public MDScope {
1256 friend class LLVMContextImpl;
1257 friend class MDNode;
1261 MDNamespace(LLVMContext &Context, StorageType Storage, unsigned Line,
1262 ArrayRef<Metadata *> Ops)
1263 : MDScope(Context, MDNamespaceKind, Storage, dwarf::DW_TAG_namespace,
1268 static MDNamespace *getImpl(LLVMContext &Context, MDScope *Scope,
1269 MDFile *File, StringRef Name, unsigned Line,
1270 StorageType Storage, bool ShouldCreate = true) {
1271 return getImpl(Context, Scope, File, getCanonicalMDString(Context, Name),
1272 Line, Storage, ShouldCreate);
1274 static MDNamespace *getImpl(LLVMContext &Context, Metadata *Scope,
1275 Metadata *File, MDString *Name, unsigned Line,
1276 StorageType Storage, bool ShouldCreate = true);
1278 TempMDNamespace cloneImpl() const {
1279 return getTemporary(getContext(), getScope(), getFile(), getName(),
1284 DEFINE_MDNODE_GET(MDNamespace, (MDScope * Scope, MDFile *File, StringRef Name,
1286 (Scope, File, Name, Line))
1287 DEFINE_MDNODE_GET(MDNamespace, (Metadata * Scope, Metadata *File,
1288 MDString *Name, unsigned Line),
1289 (Scope, File, Name, Line))
1291 TempMDNamespace clone() const { return cloneImpl(); }
1293 unsigned getLine() const { return Line; }
1294 MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
1295 StringRef getName() const { return getStringOperand(2); }
1297 Metadata *getRawScope() const { return getOperand(1); }
1298 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1300 static bool classof(const Metadata *MD) {
1301 return MD->getMetadataID() == MDNamespaceKind;
1305 /// \brief Base class for template parameters.
1306 class MDTemplateParameter : public DebugNode {
1308 MDTemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
1309 unsigned Tag, ArrayRef<Metadata *> Ops)
1310 : DebugNode(Context, ID, Storage, Tag, Ops) {}
1311 ~MDTemplateParameter() {}
1314 StringRef getName() const { return getStringOperand(0); }
1315 Metadata *getType() const { return getOperand(1); }
1317 MDString *getRawName() const { return getOperandAs<MDString>(0); }
1319 static bool classof(const Metadata *MD) {
1320 return MD->getMetadataID() == MDTemplateTypeParameterKind ||
1321 MD->getMetadataID() == MDTemplateValueParameterKind;
1325 class MDTemplateTypeParameter : public MDTemplateParameter {
1326 friend class LLVMContextImpl;
1327 friend class MDNode;
1329 MDTemplateTypeParameter(LLVMContext &Context, StorageType Storage,
1330 ArrayRef<Metadata *> Ops)
1331 : MDTemplateParameter(Context, MDTemplateTypeParameterKind, Storage,
1332 dwarf::DW_TAG_template_type_parameter, Ops) {}
1333 ~MDTemplateTypeParameter() {}
1335 static MDTemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
1336 Metadata *Type, StorageType Storage,
1337 bool ShouldCreate = true) {
1338 return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
1341 static MDTemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name,
1342 Metadata *Type, StorageType Storage,
1343 bool ShouldCreate = true);
1345 TempMDTemplateTypeParameter cloneImpl() const {
1346 return getTemporary(getContext(), getName(), getType());
1350 DEFINE_MDNODE_GET(MDTemplateTypeParameter, (StringRef Name, Metadata *Type),
1352 DEFINE_MDNODE_GET(MDTemplateTypeParameter, (MDString * Name, Metadata *Type),
1355 TempMDTemplateTypeParameter clone() const { return cloneImpl(); }
1357 static bool classof(const Metadata *MD) {
1358 return MD->getMetadataID() == MDTemplateTypeParameterKind;
1362 class MDTemplateValueParameter : public MDTemplateParameter {
1363 friend class LLVMContextImpl;
1364 friend class MDNode;
1366 MDTemplateValueParameter(LLVMContext &Context, StorageType Storage,
1367 unsigned Tag, ArrayRef<Metadata *> Ops)
1368 : MDTemplateParameter(Context, MDTemplateValueParameterKind, Storage, Tag,
1370 ~MDTemplateValueParameter() {}
1372 static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
1373 StringRef Name, Metadata *Type,
1374 Metadata *Value, StorageType Storage,
1375 bool ShouldCreate = true) {
1376 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
1377 Value, Storage, ShouldCreate);
1379 static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
1380 MDString *Name, Metadata *Type,
1381 Metadata *Value, StorageType Storage,
1382 bool ShouldCreate = true);
1384 TempMDTemplateValueParameter cloneImpl() const {
1385 return getTemporary(getContext(), getTag(), getName(), getType(),
1390 DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, StringRef Name,
1391 Metadata *Type, Metadata *Value),
1392 (Tag, Name, Type, Value))
1393 DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, MDString *Name,
1394 Metadata *Type, Metadata *Value),
1395 (Tag, Name, Type, Value))
1397 TempMDTemplateValueParameter clone() const { return cloneImpl(); }
1399 Metadata *getValue() const { return getOperand(2); }
1401 static bool classof(const Metadata *MD) {
1402 return MD->getMetadataID() == MDTemplateValueParameterKind;
1406 /// \brief Base class for variables.
1408 /// TODO: Hardcode to DW_TAG_variable.
1409 class MDVariable : public DebugNode {
1413 MDVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
1414 unsigned Line, ArrayRef<Metadata *> Ops)
1415 : DebugNode(C, ID, Storage, Tag, Ops), Line(Line) {}
1419 unsigned getLine() const { return Line; }
1420 MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
1421 StringRef getName() const { return getStringOperand(1); }
1422 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
1423 Metadata *getType() const { return getRawType(); }
1425 Metadata *getRawScope() const { return getOperand(0); }
1426 MDString *getRawName() const { return getOperandAs<MDString>(1); }
1427 Metadata *getRawFile() const { return getOperand(2); }
1428 Metadata *getRawType() const { return getOperand(3); }
1430 static bool classof(const Metadata *MD) {
1431 return MD->getMetadataID() == MDLocalVariableKind ||
1432 MD->getMetadataID() == MDGlobalVariableKind;
1436 /// \brief Global variables.
1438 /// TODO: Remove DisplayName. It's always equal to Name.
1439 class MDGlobalVariable : public MDVariable {
1440 friend class LLVMContextImpl;
1441 friend class MDNode;
1446 MDGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
1447 bool IsLocalToUnit, bool IsDefinition,
1448 ArrayRef<Metadata *> Ops)
1449 : MDVariable(C, MDGlobalVariableKind, Storage, dwarf::DW_TAG_variable,
1451 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
1452 ~MDGlobalVariable() {}
1454 static MDGlobalVariable *
1455 getImpl(LLVMContext &Context, MDScope *Scope, StringRef Name,
1456 StringRef LinkageName, MDFile *File, unsigned Line, Metadata *Type,
1457 bool IsLocalToUnit, bool IsDefinition, ConstantAsMetadata *Variable,
1458 MDDerivedType *StaticDataMemberDeclaration, StorageType Storage,
1459 bool ShouldCreate = true) {
1460 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1461 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1462 IsLocalToUnit, IsDefinition, Variable,
1463 StaticDataMemberDeclaration, Storage, ShouldCreate);
1465 static MDGlobalVariable *
1466 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1467 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1468 bool IsLocalToUnit, bool IsDefinition, Metadata *Variable,
1469 Metadata *StaticDataMemberDeclaration, StorageType Storage,
1470 bool ShouldCreate = true);
1472 TempMDGlobalVariable cloneImpl() const {
1473 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1474 getFile(), getLine(), getType(), isLocalToUnit(),
1475 isDefinition(), getVariable(),
1476 getStaticDataMemberDeclaration());
1480 DEFINE_MDNODE_GET(MDGlobalVariable,
1481 (MDScope * Scope, StringRef Name, StringRef LinkageName,
1482 MDFile *File, unsigned Line, Metadata *Type,
1483 bool IsLocalToUnit, bool IsDefinition,
1484 ConstantAsMetadata *Variable,
1485 MDDerivedType *StaticDataMemberDeclaration),
1486 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1487 IsDefinition, Variable, StaticDataMemberDeclaration))
1488 DEFINE_MDNODE_GET(MDGlobalVariable,
1489 (Metadata * Scope, MDString *Name, MDString *LinkageName,
1490 Metadata *File, unsigned Line, Metadata *Type,
1491 bool IsLocalToUnit, bool IsDefinition, Metadata *Variable,
1492 Metadata *StaticDataMemberDeclaration),
1493 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1494 IsDefinition, Variable, StaticDataMemberDeclaration))
1496 TempMDGlobalVariable clone() const { return cloneImpl(); }
1498 bool isLocalToUnit() const { return IsLocalToUnit; }
1499 bool isDefinition() const { return IsDefinition; }
1500 StringRef getDisplayName() const { return getStringOperand(4); }
1501 StringRef getLinkageName() const { return getStringOperand(5); }
1502 ConstantAsMetadata *getVariable() const {
1503 return cast_or_null<ConstantAsMetadata>(getRawVariable());
1505 MDDerivedType *getStaticDataMemberDeclaration() const {
1506 return cast_or_null<MDDerivedType>(getRawStaticDataMemberDeclaration());
1509 MDString *getRawLinkageName() const { return getOperandAs<MDString>(5); }
1510 Metadata *getRawVariable() const { return getOperand(6); }
1511 Metadata *getRawStaticDataMemberDeclaration() const { return getOperand(7); }
1513 static bool classof(const Metadata *MD) {
1514 return MD->getMetadataID() == MDGlobalVariableKind;
1518 /// \brief Local variable.
1520 /// TODO: Split between arguments and otherwise.
1521 /// TODO: Use \c DW_TAG_variable instead of fake tags.
1522 /// TODO: Split up flags.
1523 class MDLocalVariable : public MDVariable {
1524 friend class LLVMContextImpl;
1525 friend class MDNode;
1530 MDLocalVariable(LLVMContext &C, StorageType Storage, unsigned Tag,
1531 unsigned Line, unsigned Arg, unsigned Flags,
1532 ArrayRef<Metadata *> Ops)
1533 : MDVariable(C, MDLocalVariableKind, Storage, Tag, Line, Ops), Arg(Arg),
1535 ~MDLocalVariable() {}
1537 static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag,
1538 MDScope *Scope, StringRef Name, MDFile *File,
1539 unsigned Line, Metadata *Type, unsigned Arg,
1540 unsigned Flags, MDLocation *InlinedAt,
1541 StorageType Storage,
1542 bool ShouldCreate = true) {
1543 return getImpl(Context, Tag, Scope, getCanonicalMDString(Context, Name),
1544 File, Line, Type, Arg, Flags, InlinedAt, Storage,
1547 static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag,
1548 Metadata *Scope, MDString *Name,
1549 Metadata *File, unsigned Line, Metadata *Type,
1550 unsigned Arg, unsigned Flags,
1551 Metadata *InlinedAt, StorageType Storage,
1552 bool ShouldCreate = true);
1554 TempMDLocalVariable cloneImpl() const {
1555 return getTemporary(getContext(), getTag(), getScope(), getName(),
1556 getFile(), getLine(), getType(), getArg(), getFlags(),
1561 DEFINE_MDNODE_GET(MDLocalVariable,
1562 (unsigned Tag, MDLocalScope *Scope, StringRef Name,
1563 MDFile *File, unsigned Line, Metadata *Type, unsigned Arg,
1564 unsigned Flags, MDLocation *InlinedAt = nullptr),
1565 (Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
1566 DEFINE_MDNODE_GET(MDLocalVariable,
1567 (unsigned Tag, Metadata *Scope, MDString *Name,
1568 Metadata *File, unsigned Line, Metadata *Type,
1569 unsigned Arg, unsigned Flags,
1570 Metadata *InlinedAt = nullptr),
1571 (Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
1573 TempMDLocalVariable clone() const { return cloneImpl(); }
1575 /// \brief Get the local scope for this variable.
1577 /// Variables must be defined in a local scope.
1578 MDLocalScope *getScope() const {
1579 return cast<MDLocalScope>(MDVariable::getScope());
1582 unsigned getArg() const { return Arg; }
1583 unsigned getFlags() const { return Flags; }
1584 MDLocation *getInlinedAt() const {
1585 return cast_or_null<MDLocation>(getRawInlinedAt());
1588 Metadata *getRawInlinedAt() const { return getOperand(4); }
1590 /// \brief Get an inlined version of this variable.
1592 /// Returns a version of this with \a getAlinedAt() set to \c InlinedAt.
1593 MDLocalVariable *withInline(MDLocation *InlinedAt) const {
1594 if (InlinedAt == getInlinedAt())
1595 return const_cast<MDLocalVariable *>(this);
1596 auto Temp = clone();
1597 Temp->replaceOperandWith(4, InlinedAt);
1598 return replaceWithUniqued(std::move(Temp));
1600 MDLocalVariable *withoutInline() const { return withInline(nullptr); }
1602 static bool classof(const Metadata *MD) {
1603 return MD->getMetadataID() == MDLocalVariableKind;
1607 /// \brief DWARF expression.
1609 /// TODO: Co-allocate the expression elements.
1610 /// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
1612 class MDExpression : public MDNode {
1613 friend class LLVMContextImpl;
1614 friend class MDNode;
1616 std::vector<uint64_t> Elements;
1618 MDExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
1619 : MDNode(C, MDExpressionKind, Storage, None),
1620 Elements(Elements.begin(), Elements.end()) {}
1623 static MDExpression *getImpl(LLVMContext &Context,
1624 ArrayRef<uint64_t> Elements, StorageType Storage,
1625 bool ShouldCreate = true);
1627 TempMDExpression cloneImpl() const {
1628 return getTemporary(getContext(), getElements());
1632 DEFINE_MDNODE_GET(MDExpression, (ArrayRef<uint64_t> Elements), (Elements))
1634 TempMDExpression clone() const { return cloneImpl(); }
1636 ArrayRef<uint64_t> getElements() const { return Elements; }
1638 unsigned getNumElements() const { return Elements.size(); }
1639 uint64_t getElement(unsigned I) const {
1640 assert(I < Elements.size() && "Index out of range");
1644 typedef ArrayRef<uint64_t>::iterator element_iterator;
1645 element_iterator elements_begin() const { return getElements().begin(); }
1646 element_iterator elements_end() const { return getElements().end(); }
1648 /// \brief A lightweight wrapper around an expression operand.
1650 /// TODO: Store arguments directly and change \a MDExpression to store a
1656 explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
1658 const uint64_t *get() const { return Op; }
1660 /// \brief Get the operand code.
1661 uint64_t getOp() const { return *Op; }
1663 /// \brief Get an argument to the operand.
1665 /// Never returns the operand itself.
1666 uint64_t getArg(unsigned I) const { return Op[I + 1]; }
1668 unsigned getNumArgs() const { return getSize() - 1; }
1670 /// \brief Return the size of the operand.
1672 /// Return the number of elements in the operand (1 + args).
1673 unsigned getSize() const;
1676 /// \brief An iterator for expression operands.
1677 class expr_op_iterator
1678 : public std::iterator<std::input_iterator_tag, ExprOperand> {
1682 explicit expr_op_iterator(element_iterator I) : Op(I) {}
1684 element_iterator getBase() const { return Op.get(); }
1685 const ExprOperand &operator*() const { return Op; }
1686 const ExprOperand *operator->() const { return &Op; }
1688 expr_op_iterator &operator++() {
1692 expr_op_iterator operator++(int) {
1693 expr_op_iterator T(*this);
1698 bool operator==(const expr_op_iterator &X) const {
1699 return getBase() == X.getBase();
1701 bool operator!=(const expr_op_iterator &X) const {
1702 return getBase() != X.getBase();
1706 void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
1709 /// \brief Visit the elements via ExprOperand wrappers.
1711 /// These range iterators visit elements through \a ExprOperand wrappers.
1712 /// This is not guaranteed to be a valid range unless \a isValid() gives \c
1715 /// \pre \a isValid() gives \c true.
1717 expr_op_iterator expr_op_begin() const {
1718 return expr_op_iterator(elements_begin());
1720 expr_op_iterator expr_op_end() const {
1721 return expr_op_iterator(elements_end());
1725 bool isValid() const;
1727 static bool classof(const Metadata *MD) {
1728 return MD->getMetadataID() == MDExpressionKind;
1732 class MDObjCProperty : public DebugNode {
1733 friend class LLVMContextImpl;
1734 friend class MDNode;
1737 unsigned Attributes;
1739 MDObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
1740 unsigned Attributes, ArrayRef<Metadata *> Ops)
1741 : DebugNode(C, MDObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property,
1743 Line(Line), Attributes(Attributes) {}
1744 ~MDObjCProperty() {}
1746 static MDObjCProperty *
1747 getImpl(LLVMContext &Context, StringRef Name, MDFile *File, unsigned Line,
1748 StringRef GetterName, StringRef SetterName, unsigned Attributes,
1749 MDType *Type, StorageType Storage, bool ShouldCreate = true) {
1750 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
1751 getCanonicalMDString(Context, GetterName),
1752 getCanonicalMDString(Context, SetterName), Attributes, Type,
1753 Storage, ShouldCreate);
1755 static MDObjCProperty *getImpl(LLVMContext &Context, MDString *Name,
1756 Metadata *File, unsigned Line,
1757 MDString *GetterName, MDString *SetterName,
1758 unsigned Attributes, Metadata *Type,
1759 StorageType Storage, bool ShouldCreate = true);
1761 TempMDObjCProperty cloneImpl() const {
1762 return getTemporary(getContext(), getName(), getFile(), getLine(),
1763 getGetterName(), getSetterName(), getAttributes(),
1768 DEFINE_MDNODE_GET(MDObjCProperty,
1769 (StringRef Name, MDFile *File, unsigned Line,
1770 StringRef GetterName, StringRef SetterName,
1771 unsigned Attributes, MDType *Type),
1772 (Name, File, Line, GetterName, SetterName, Attributes,
1774 DEFINE_MDNODE_GET(MDObjCProperty,
1775 (MDString * Name, Metadata *File, unsigned Line,
1776 MDString *GetterName, MDString *SetterName,
1777 unsigned Attributes, Metadata *Type),
1778 (Name, File, Line, GetterName, SetterName, Attributes,
1781 TempMDObjCProperty clone() const { return cloneImpl(); }
1783 unsigned getLine() const { return Line; }
1784 unsigned getAttributes() const { return Attributes; }
1785 StringRef getName() const { return getStringOperand(0); }
1786 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
1787 StringRef getGetterName() const { return getStringOperand(2); }
1788 StringRef getSetterName() const { return getStringOperand(3); }
1789 MDType *getType() const { return cast_or_null<MDType>(getRawType()); }
1791 MDString *getRawName() const { return getOperandAs<MDString>(0); }
1792 Metadata *getRawFile() const { return getOperand(1); }
1793 MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }
1794 MDString *getRawSetterName() const { return getOperandAs<MDString>(3); }
1795 Metadata *getRawType() const { return getOperand(4); }
1797 static bool classof(const Metadata *MD) {
1798 return MD->getMetadataID() == MDObjCPropertyKind;
1802 class MDImportedEntity : public DebugNode {
1803 friend class LLVMContextImpl;
1804 friend class MDNode;
1808 MDImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
1809 unsigned Line, ArrayRef<Metadata *> Ops)
1810 : DebugNode(C, MDImportedEntityKind, Storage, Tag, Ops), Line(Line) {}
1811 ~MDImportedEntity() {}
1813 static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
1814 MDScope *Scope, Metadata *Entity,
1815 unsigned Line, StringRef Name,
1816 StorageType Storage,
1817 bool ShouldCreate = true) {
1818 return getImpl(Context, Tag, Scope, Entity, Line,
1819 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
1821 static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
1822 Metadata *Scope, Metadata *Entity,
1823 unsigned Line, MDString *Name,
1824 StorageType Storage,
1825 bool ShouldCreate = true);
1827 TempMDImportedEntity cloneImpl() const {
1828 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
1829 getLine(), getName());
1833 DEFINE_MDNODE_GET(MDImportedEntity,
1834 (unsigned Tag, MDScope *Scope, Metadata *Entity,
1835 unsigned Line, StringRef Name = ""),
1836 (Tag, Scope, Entity, Line, Name))
1837 DEFINE_MDNODE_GET(MDImportedEntity,
1838 (unsigned Tag, Metadata *Scope, Metadata *Entity,
1839 unsigned Line, MDString *Name),
1840 (Tag, Scope, Entity, Line, Name))
1842 TempMDImportedEntity clone() const { return cloneImpl(); }
1844 unsigned getLine() const { return Line; }
1845 MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
1846 Metadata *getEntity() const { return getRawEntity(); }
1847 StringRef getName() const { return getStringOperand(2); }
1849 Metadata *getRawScope() const { return getOperand(0); }
1850 Metadata *getRawEntity() const { return getOperand(1); }
1851 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1853 static bool classof(const Metadata *MD) {
1854 return MD->getMetadataID() == MDImportedEntityKind;
1858 } // end namespace llvm
1860 #undef DEFINE_MDNODE_GET_UNPACK_IMPL
1861 #undef DEFINE_MDNODE_GET_UNPACK
1862 #undef DEFINE_MDNODE_GET