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 static bool classof(const Metadata *MD) {
82 switch (MD->getMetadataID()) {
85 case GenericDebugNodeKind:
87 case MDEnumeratorKind:
89 case MDDerivedTypeKind:
90 case MDCompositeTypeKind:
91 case MDSubroutineTypeKind:
93 case MDCompileUnitKind:
94 case MDSubprogramKind:
95 case MDLexicalBlockKind:
96 case MDLexicalBlockFileKind:
98 case MDTemplateTypeParameterKind:
99 case MDTemplateValueParameterKind:
100 case MDGlobalVariableKind:
101 case MDLocalVariableKind:
102 case MDObjCPropertyKind:
103 case MDImportedEntityKind:
109 /// \brief Generic tagged DWARF-like metadata node.
111 /// An un-specialized DWARF-like metadata node. The first operand is a
112 /// (possibly empty) null-separated \a MDString header that contains arbitrary
113 /// fields. The remaining operands are \a dwarf_operands(), and are pointers
114 /// to other metadata.
115 class GenericDebugNode : public DebugNode {
116 friend class LLVMContextImpl;
119 GenericDebugNode(LLVMContext &C, StorageType Storage, unsigned Hash,
120 unsigned Tag, ArrayRef<Metadata *> Ops1,
121 ArrayRef<Metadata *> Ops2)
122 : DebugNode(C, GenericDebugNodeKind, Storage, Tag, Ops1, Ops2) {
125 ~GenericDebugNode() { dropAllReferences(); }
127 void setHash(unsigned Hash) { SubclassData32 = Hash; }
128 void recalculateHash();
130 static GenericDebugNode *getImpl(LLVMContext &Context, unsigned Tag,
132 ArrayRef<Metadata *> DwarfOps,
134 bool ShouldCreate = true) {
135 return getImpl(Context, Tag, getCanonicalMDString(Context, Header),
136 DwarfOps, Storage, ShouldCreate);
139 static GenericDebugNode *getImpl(LLVMContext &Context, unsigned Tag,
141 ArrayRef<Metadata *> DwarfOps,
143 bool ShouldCreate = true);
145 TempGenericDebugNode cloneImpl() const {
147 getContext(), getTag(), getHeader(),
148 SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end()));
152 unsigned getHash() const { return SubclassData32; }
154 DEFINE_MDNODE_GET(GenericDebugNode, (unsigned Tag, StringRef Header,
155 ArrayRef<Metadata *> DwarfOps),
156 (Tag, Header, DwarfOps))
157 DEFINE_MDNODE_GET(GenericDebugNode, (unsigned Tag, MDString *Header,
158 ArrayRef<Metadata *> DwarfOps),
159 (Tag, Header, DwarfOps))
161 /// \brief Return a (temporary) clone of this.
162 TempGenericDebugNode clone() const { return cloneImpl(); }
164 unsigned getTag() const { return SubclassData16; }
165 StringRef getHeader() const { return getStringOperand(0); }
167 op_iterator dwarf_op_begin() const { return op_begin() + 1; }
168 op_iterator dwarf_op_end() const { return op_end(); }
169 op_range dwarf_operands() const {
170 return op_range(dwarf_op_begin(), dwarf_op_end());
173 unsigned getNumDwarfOperands() const { return getNumOperands() - 1; }
174 const MDOperand &getDwarfOperand(unsigned I) const {
175 return getOperand(I + 1);
177 void replaceDwarfOperandWith(unsigned I, Metadata *New) {
178 replaceOperandWith(I + 1, New);
181 static bool classof(const Metadata *MD) {
182 return MD->getMetadataID() == GenericDebugNodeKind;
186 /// \brief Array subrange.
188 /// TODO: Merge into node for DW_TAG_array_type, which should have a custom
190 class MDSubrange : public DebugNode {
191 friend class LLVMContextImpl;
197 MDSubrange(LLVMContext &C, StorageType Storage, int64_t Count, int64_t Lo)
198 : DebugNode(C, MDSubrangeKind, Storage, dwarf::DW_TAG_subrange_type,
200 Count(Count), Lo(Lo) {}
203 static MDSubrange *getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
204 StorageType Storage, bool ShouldCreate = true);
206 TempMDSubrange cloneImpl() const {
207 return getTemporary(getContext(), getCount(), getLo());
211 DEFINE_MDNODE_GET(MDSubrange, (int64_t Count, int64_t Lo = 0), (Count, Lo))
213 TempMDSubrange clone() const { return cloneImpl(); }
215 int64_t getLo() const { return Lo; }
216 int64_t getCount() const { return Count; }
218 static bool classof(const Metadata *MD) {
219 return MD->getMetadataID() == MDSubrangeKind;
223 /// \brief Enumeration value.
225 /// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
226 /// longer creates a type cycle.
227 class MDEnumerator : public DebugNode {
228 friend class LLVMContextImpl;
233 MDEnumerator(LLVMContext &C, StorageType Storage, int64_t Value,
234 ArrayRef<Metadata *> Ops)
235 : DebugNode(C, MDEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
239 static MDEnumerator *getImpl(LLVMContext &Context, int64_t Value,
240 StringRef Name, StorageType Storage,
241 bool ShouldCreate = true) {
242 return getImpl(Context, Value, getCanonicalMDString(Context, Name), Storage,
245 static MDEnumerator *getImpl(LLVMContext &Context, int64_t Value,
246 MDString *Name, StorageType Storage,
247 bool ShouldCreate = true);
249 TempMDEnumerator cloneImpl() const {
250 return getTemporary(getContext(), getValue(), getName());
254 DEFINE_MDNODE_GET(MDEnumerator, (int64_t Value, StringRef Name),
256 DEFINE_MDNODE_GET(MDEnumerator, (int64_t Value, MDString *Name),
259 TempMDEnumerator clone() const { return cloneImpl(); }
261 int64_t getValue() const { return Value; }
262 StringRef getName() const { return getStringOperand(0); }
264 MDString *getRawName() const { return getOperandAs<MDString>(0); }
266 static bool classof(const Metadata *MD) {
267 return MD->getMetadataID() == MDEnumeratorKind;
271 /// \brief Base class for scope-like contexts.
273 /// Base class for lexical scopes and types (which are also declaration
276 /// TODO: Separate the concepts of declaration contexts and lexical scopes.
277 class MDScope : public DebugNode {
279 MDScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
280 ArrayRef<Metadata *> Ops)
281 : DebugNode(C, ID, Storage, Tag, Ops) {}
285 // FIXME: Downcast to MDFile once we've verified all subclasses.
286 Metadata *getFile() const { return getRawFile(); }
288 /// \brief Return the raw underlying file.
290 /// An \a MDFile is an \a MDScope, but it doesn't point at a separate file
291 /// (it\em is the file). If \c this is an \a MDFile, we need to return \c
292 /// this. Otherwise, return the first operand, which is where all other
293 /// subclasses store their file pointer.
294 Metadata *getRawFile() const {
295 return isa<MDFile>(this) ? const_cast<MDScope *>(this)
296 : static_cast<Metadata *>(getOperand(0));
299 static bool classof(const Metadata *MD) {
300 switch (MD->getMetadataID()) {
303 case MDBasicTypeKind:
304 case MDDerivedTypeKind:
305 case MDCompositeTypeKind:
306 case MDSubroutineTypeKind:
308 case MDCompileUnitKind:
309 case MDSubprogramKind:
310 case MDLexicalBlockKind:
311 case MDLexicalBlockFileKind:
312 case MDNamespaceKind:
320 /// TODO: Merge with directory/file node (including users).
321 /// TODO: Canonicalize paths on creation.
322 class MDFile : public MDScope {
323 friend class LLVMContextImpl;
326 MDFile(LLVMContext &C, StorageType Storage, ArrayRef<Metadata *> Ops)
327 : MDScope(C, MDFileKind, Storage, dwarf::DW_TAG_file_type, Ops) {}
330 static MDFile *getImpl(LLVMContext &Context, StringRef Filename,
331 StringRef Directory, StorageType Storage,
332 bool ShouldCreate = true) {
333 return getImpl(Context, getCanonicalMDString(Context, Filename),
334 getCanonicalMDString(Context, Directory), Storage,
337 static MDFile *getImpl(LLVMContext &Context, MDString *Filename,
338 MDString *Directory, StorageType Storage,
339 bool ShouldCreate = true);
341 TempMDFile cloneImpl() const {
342 return getTemporary(getContext(), getFilename(), getDirectory());
346 DEFINE_MDNODE_GET(MDFile, (StringRef Filename, StringRef Directory),
347 (Filename, Directory))
348 DEFINE_MDNODE_GET(MDFile, (MDString * Filename, MDString *Directory),
349 (Filename, Directory))
351 TempMDFile clone() const { return cloneImpl(); }
353 StringRef getFilename() const { return getStringOperand(0); }
354 StringRef getDirectory() const { return getStringOperand(1); }
356 MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
357 MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
359 static bool classof(const Metadata *MD) {
360 return MD->getMetadataID() == MDFileKind;
364 /// \brief Base class for types.
366 /// TODO: Remove the hardcoded name and context, since many types don't use
368 /// TODO: Split up flags.
369 class MDType : public MDScope {
373 uint64_t AlignInBits;
374 uint64_t OffsetInBits;
377 MDType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
378 unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
379 uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
380 : MDScope(C, ID, Storage, Tag, Ops), Line(Line), Flags(Flags),
381 SizeInBits(SizeInBits), AlignInBits(AlignInBits),
382 OffsetInBits(OffsetInBits) {}
386 TempMDType clone() const {
387 return TempMDType(cast<MDType>(MDNode::clone().release()));
390 unsigned getLine() const { return Line; }
391 uint64_t getSizeInBits() const { return SizeInBits; }
392 uint64_t getAlignInBits() const { return AlignInBits; }
393 uint64_t getOffsetInBits() const { return OffsetInBits; }
394 unsigned getFlags() const { return Flags; }
396 // FIXME: Remove this once MDScope::getFile() does the same.
397 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
399 Metadata *getScope() const { return getRawScope(); }
400 StringRef getName() const { return getStringOperand(2); }
403 Metadata *getRawScope() const { return getOperand(1); }
404 MDString *getRawName() const { return getOperandAs<MDString>(2); }
406 void setFlags(unsigned NewFlags) {
407 assert(!isUniqued() && "Cannot set flags on uniqued nodes");
411 static bool classof(const Metadata *MD) {
412 switch (MD->getMetadataID()) {
415 case MDBasicTypeKind:
416 case MDDerivedTypeKind:
417 case MDCompositeTypeKind:
418 case MDSubroutineTypeKind:
424 /// \brief Basic type.
426 /// TODO: Split out DW_TAG_unspecified_type.
427 /// TODO: Drop unused accessors.
428 class MDBasicType : public MDType {
429 friend class LLVMContextImpl;
434 MDBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
435 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Encoding,
436 ArrayRef<Metadata *> Ops)
437 : MDType(C, MDBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
439 Encoding(Encoding) {}
442 static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
443 StringRef Name, uint64_t SizeInBits,
444 uint64_t AlignInBits, unsigned Encoding,
445 StorageType Storage, bool ShouldCreate = true) {
446 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
447 SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate);
449 static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
450 MDString *Name, uint64_t SizeInBits,
451 uint64_t AlignInBits, unsigned Encoding,
452 StorageType Storage, bool ShouldCreate = true);
454 TempMDBasicType cloneImpl() const {
455 return getTemporary(getContext(), getTag(), getName(), getSizeInBits(),
456 getAlignInBits(), getEncoding());
460 DEFINE_MDNODE_GET(MDBasicType, (unsigned Tag, StringRef Name),
461 (Tag, Name, 0, 0, 0))
462 DEFINE_MDNODE_GET(MDBasicType,
463 (unsigned Tag, StringRef Name, uint64_t SizeInBits,
464 uint64_t AlignInBits, unsigned Encoding),
465 (Tag, Name, SizeInBits, AlignInBits, Encoding))
466 DEFINE_MDNODE_GET(MDBasicType,
467 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
468 uint64_t AlignInBits, unsigned Encoding),
469 (Tag, Name, SizeInBits, AlignInBits, Encoding))
471 TempMDBasicType clone() const { return cloneImpl(); }
473 unsigned getEncoding() const { return Encoding; }
475 static bool classof(const Metadata *MD) {
476 return MD->getMetadataID() == MDBasicTypeKind;
480 /// \brief Base class for MDDerivedType and MDCompositeType.
482 /// TODO: Delete; they're not really related.
483 class MDDerivedTypeBase : public MDType {
485 MDDerivedTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
486 unsigned Tag, unsigned Line, uint64_t SizeInBits,
487 uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
488 ArrayRef<Metadata *> Ops)
489 : MDType(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
491 ~MDDerivedTypeBase() {}
494 Metadata *getBaseType() const { return getRawBaseType(); }
495 Metadata *getRawBaseType() const { return getOperand(3); }
497 static bool classof(const Metadata *MD) {
498 return MD->getMetadataID() == MDDerivedTypeKind ||
499 MD->getMetadataID() == MDCompositeTypeKind ||
500 MD->getMetadataID() == MDSubroutineTypeKind;
504 /// \brief Derived types.
506 /// This includes qualified types, pointers, references, friends, typedefs, and
509 /// TODO: Split out members (inheritance, fields, methods, etc.).
510 class MDDerivedType : public MDDerivedTypeBase {
511 friend class LLVMContextImpl;
514 MDDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
515 unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
516 uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
517 : MDDerivedTypeBase(C, MDDerivedTypeKind, Storage, Tag, Line, SizeInBits,
518 AlignInBits, OffsetInBits, Flags, Ops) {}
521 static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
522 StringRef Name, MDFile *File, unsigned Line,
523 Metadata *Scope, Metadata *BaseType,
524 uint64_t SizeInBits, uint64_t AlignInBits,
525 uint64_t OffsetInBits, unsigned Flags,
526 Metadata *ExtraData, StorageType Storage,
527 bool ShouldCreate = true) {
528 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
529 Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
530 Flags, ExtraData, Storage, ShouldCreate);
532 static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
533 MDString *Name, Metadata *File, unsigned Line,
534 Metadata *Scope, Metadata *BaseType,
535 uint64_t SizeInBits, uint64_t AlignInBits,
536 uint64_t OffsetInBits, unsigned Flags,
537 Metadata *ExtraData, StorageType Storage,
538 bool ShouldCreate = true);
540 TempMDDerivedType cloneImpl() const {
541 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
542 getScope(), getBaseType(), getSizeInBits(),
543 getAlignInBits(), getOffsetInBits(), getFlags(),
548 DEFINE_MDNODE_GET(MDDerivedType,
549 (unsigned Tag, MDString *Name, Metadata *File,
550 unsigned Line, Metadata *Scope, Metadata *BaseType,
551 uint64_t SizeInBits, uint64_t AlignInBits,
552 uint64_t OffsetInBits, unsigned Flags,
553 Metadata *ExtraData = nullptr),
554 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
555 AlignInBits, OffsetInBits, Flags, ExtraData))
556 DEFINE_MDNODE_GET(MDDerivedType,
557 (unsigned Tag, StringRef Name, MDFile *File,
558 unsigned Line, Metadata *Scope, Metadata *BaseType,
559 uint64_t SizeInBits, uint64_t AlignInBits,
560 uint64_t OffsetInBits, unsigned Flags,
561 Metadata *ExtraData = nullptr),
562 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
563 AlignInBits, OffsetInBits, Flags, ExtraData))
565 TempMDDerivedType clone() const { return cloneImpl(); }
567 /// \brief Get extra data associated with this derived type.
569 /// Class type for pointer-to-members, objective-c property node for ivars,
570 /// or global constant wrapper for static members.
572 /// TODO: Separate out types that need this extra operand: pointer-to-member
573 /// types and member fields (static members and ivars).
574 Metadata *getExtraData() const { return getRawExtraData(); }
575 Metadata *getRawExtraData() const { return getOperand(4); }
577 static bool classof(const Metadata *MD) {
578 return MD->getMetadataID() == MDDerivedTypeKind;
582 /// \brief Base class for MDCompositeType and MDSubroutineType.
584 /// TODO: Delete; they're not really related.
585 class MDCompositeTypeBase : public MDDerivedTypeBase {
586 unsigned RuntimeLang;
589 MDCompositeTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
590 unsigned Tag, unsigned Line, unsigned RuntimeLang,
591 uint64_t SizeInBits, uint64_t AlignInBits,
592 uint64_t OffsetInBits, unsigned Flags,
593 ArrayRef<Metadata *> Ops)
594 : MDDerivedTypeBase(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits,
595 OffsetInBits, Flags, Ops),
596 RuntimeLang(RuntimeLang) {}
597 ~MDCompositeTypeBase() {}
600 MDTuple *getElements() const {
601 return cast_or_null<MDTuple>(getRawElements());
603 Metadata *getVTableHolder() const { return getRawVTableHolder(); }
604 MDTuple *getTemplateParams() const {
605 return cast_or_null<MDTuple>(getRawTemplateParams());
607 StringRef getIdentifier() const { return getStringOperand(7); }
608 unsigned getRuntimeLang() const { return RuntimeLang; }
610 Metadata *getRawElements() const { return getOperand(4); }
611 Metadata *getRawVTableHolder() const { return getOperand(5); }
612 Metadata *getRawTemplateParams() const { return getOperand(6); }
613 MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
615 /// \brief Replace operands.
617 /// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
618 /// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
619 /// of its movement if necessary.
621 void replaceElements(MDTuple *Elements) {
623 if (auto *Old = cast_or_null<MDTuple>(getElements()))
624 for (const auto &Op : Old->operands())
625 assert(std::find(Elements->op_begin(), Elements->op_end(), Op) &&
626 "Lost a member during member list replacement");
628 replaceOperandWith(4, Elements);
630 void replaceVTableHolder(Metadata *VTableHolder) {
631 replaceOperandWith(5, VTableHolder);
633 void replaceTemplateParams(MDTuple *TemplateParams) {
634 replaceOperandWith(6, TemplateParams);
638 static bool classof(const Metadata *MD) {
639 return MD->getMetadataID() == MDCompositeTypeKind ||
640 MD->getMetadataID() == MDSubroutineTypeKind;
644 /// \brief Composite types.
646 /// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
647 /// TODO: Create a custom, unrelated node for DW_TAG_array_type.
648 class MDCompositeType : public MDCompositeTypeBase {
649 friend class LLVMContextImpl;
652 MDCompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
653 unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
654 uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
655 ArrayRef<Metadata *> Ops)
656 : MDCompositeTypeBase(C, MDCompositeTypeKind, Storage, Tag, Line,
657 RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
659 ~MDCompositeType() {}
661 static MDCompositeType *
662 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
663 unsigned Line, Metadata *Scope, Metadata *BaseType,
664 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
665 uint64_t Flags, Metadata *Elements, unsigned RuntimeLang,
666 Metadata *VTableHolder, Metadata *TemplateParams,
667 StringRef Identifier, StorageType Storage, bool ShouldCreate = true) {
668 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
669 Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
670 Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
671 getCanonicalMDString(Context, Identifier), Storage,
674 static MDCompositeType *
675 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
676 unsigned Line, Metadata *Scope, Metadata *BaseType,
677 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
678 unsigned Flags, Metadata *Elements, unsigned RuntimeLang,
679 Metadata *VTableHolder, Metadata *TemplateParams,
680 MDString *Identifier, StorageType Storage, bool ShouldCreate = true);
682 TempMDCompositeType cloneImpl() const {
683 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
684 getScope(), getBaseType(), getSizeInBits(),
685 getAlignInBits(), getOffsetInBits(), getFlags(),
686 getElements(), getRuntimeLang(), getVTableHolder(),
687 getTemplateParams(), getIdentifier());
691 DEFINE_MDNODE_GET(MDCompositeType,
692 (unsigned Tag, StringRef Name, Metadata *File,
693 unsigned Line, Metadata *Scope, Metadata *BaseType,
694 uint64_t SizeInBits, uint64_t AlignInBits,
695 uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
696 unsigned RuntimeLang, Metadata *VTableHolder,
697 Metadata *TemplateParams = nullptr,
698 StringRef Identifier = ""),
699 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
700 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
701 VTableHolder, TemplateParams, Identifier))
702 DEFINE_MDNODE_GET(MDCompositeType,
703 (unsigned Tag, MDString *Name, Metadata *File,
704 unsigned Line, Metadata *Scope, Metadata *BaseType,
705 uint64_t SizeInBits, uint64_t AlignInBits,
706 uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
707 unsigned RuntimeLang, Metadata *VTableHolder,
708 Metadata *TemplateParams = nullptr,
709 MDString *Identifier = nullptr),
710 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
711 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
712 VTableHolder, TemplateParams, Identifier))
714 TempMDCompositeType clone() const { return cloneImpl(); }
716 static bool classof(const Metadata *MD) {
717 return MD->getMetadataID() == MDCompositeTypeKind;
721 /// \brief Type array for a subprogram.
723 /// TODO: Detach from CompositeType, and fold the array of types in directly
725 class MDSubroutineType : public MDCompositeTypeBase {
726 friend class LLVMContextImpl;
729 MDSubroutineType(LLVMContext &C, StorageType Storage, unsigned Flags,
730 ArrayRef<Metadata *> Ops)
731 : MDCompositeTypeBase(C, MDSubroutineTypeKind, Storage,
732 dwarf::DW_TAG_subroutine_type, 0, 0, 0, 0, 0, Flags,
734 ~MDSubroutineType() {}
736 static MDSubroutineType *getImpl(LLVMContext &Context, unsigned Flags,
737 Metadata *TypeArray, StorageType Storage,
738 bool ShouldCreate = true);
740 TempMDSubroutineType cloneImpl() const {
741 return getTemporary(getContext(), getFlags(), getTypeArray());
745 DEFINE_MDNODE_GET(MDSubroutineType, (unsigned Flags, Metadata *TypeArray),
748 TempMDSubroutineType clone() const { return cloneImpl(); }
750 MDTuple *getTypeArray() const { return getElements(); }
751 Metadata *getRawTypeArray() const { return getRawElements(); }
753 static bool classof(const Metadata *MD) {
754 return MD->getMetadataID() == MDSubroutineTypeKind;
758 /// \brief Compile unit.
759 class MDCompileUnit : public MDScope {
760 friend class LLVMContextImpl;
763 unsigned SourceLanguage;
765 unsigned RuntimeVersion;
766 unsigned EmissionKind;
768 MDCompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
769 bool IsOptimized, unsigned RuntimeVersion,
770 unsigned EmissionKind, ArrayRef<Metadata *> Ops)
771 : MDScope(C, MDCompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
772 SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
773 RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind) {}
776 static MDCompileUnit *
777 getImpl(LLVMContext &Context, unsigned SourceLanguage, MDFile *File,
778 StringRef Producer, bool IsOptimized, StringRef Flags,
779 unsigned RuntimeVersion, StringRef SplitDebugFilename,
780 unsigned EmissionKind, MDTuple *EnumTypes, MDTuple *RetainedTypes,
781 MDTuple *Subprograms, MDTuple *GlobalVariables,
782 MDTuple *ImportedEntities, StorageType Storage,
783 bool ShouldCreate = true) {
784 return getImpl(Context, SourceLanguage, File,
785 getCanonicalMDString(Context, Producer), IsOptimized,
786 getCanonicalMDString(Context, Flags), RuntimeVersion,
787 getCanonicalMDString(Context, SplitDebugFilename),
788 EmissionKind, EnumTypes, RetainedTypes, Subprograms,
789 GlobalVariables, ImportedEntities, Storage, ShouldCreate);
791 static MDCompileUnit *
792 getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
793 MDString *Producer, bool IsOptimized, MDString *Flags,
794 unsigned RuntimeVersion, MDString *SplitDebugFilename,
795 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
796 Metadata *Subprograms, Metadata *GlobalVariables,
797 Metadata *ImportedEntities, StorageType Storage,
798 bool ShouldCreate = true);
800 TempMDCompileUnit cloneImpl() const {
802 getContext(), getSourceLanguage(), getFile(), getProducer(),
803 isOptimized(), getFlags(), getRuntimeVersion(), getSplitDebugFilename(),
804 getEmissionKind(), getEnumTypes(), getRetainedTypes(), getSubprograms(),
805 getGlobalVariables(), getImportedEntities());
809 DEFINE_MDNODE_GET(MDCompileUnit,
810 (unsigned SourceLanguage, MDFile *File, StringRef Producer,
811 bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
812 StringRef SplitDebugFilename, unsigned EmissionKind,
813 MDTuple *EnumTypes, MDTuple *RetainedTypes,
814 MDTuple *Subprograms, MDTuple *GlobalVariables,
815 MDTuple *ImportedEntities),
816 (SourceLanguage, File, Producer, IsOptimized, Flags,
817 RuntimeVersion, SplitDebugFilename, EmissionKind,
818 EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
820 DEFINE_MDNODE_GET(MDCompileUnit,
821 (unsigned SourceLanguage, Metadata *File,
822 MDString *Producer, bool IsOptimized, MDString *Flags,
823 unsigned RuntimeVersion, MDString *SplitDebugFilename,
824 unsigned EmissionKind, Metadata *EnumTypes,
825 Metadata *RetainedTypes, Metadata *Subprograms,
826 Metadata *GlobalVariables, Metadata *ImportedEntities),
827 (SourceLanguage, File, Producer, IsOptimized, Flags,
828 RuntimeVersion, SplitDebugFilename, EmissionKind,
829 EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
832 TempMDCompileUnit clone() const { return cloneImpl(); }
834 // FIXME: Remove this once MDScope::getFile() does the same.
835 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
837 unsigned getSourceLanguage() const { return SourceLanguage; }
838 bool isOptimized() const { return IsOptimized; }
839 unsigned getRuntimeVersion() const { return RuntimeVersion; }
840 unsigned getEmissionKind() const { return EmissionKind; }
841 StringRef getProducer() const { return getStringOperand(1); }
842 StringRef getFlags() const { return getStringOperand(2); }
843 StringRef getSplitDebugFilename() const { return getStringOperand(3); }
844 MDTuple *getEnumTypes() const {
845 return cast_or_null<MDTuple>(getRawEnumTypes());
847 MDTuple *getRetainedTypes() const {
848 return cast_or_null<MDTuple>(getRawRetainedTypes());
850 MDTuple *getSubprograms() const {
851 return cast_or_null<MDTuple>(getRawSubprograms());
853 MDTuple *getGlobalVariables() const {
854 return cast_or_null<MDTuple>(getRawGlobalVariables());
856 MDTuple *getImportedEntities() const {
857 return cast_or_null<MDTuple>(getRawImportedEntities());
860 MDString *getRawProducer() const { return getOperandAs<MDString>(1); }
861 MDString *getRawFlags() const { return getOperandAs<MDString>(2); }
862 MDString *getRawSplitDebugFilename() const {
863 return getOperandAs<MDString>(3);
865 Metadata *getRawEnumTypes() const { return getOperand(4); }
866 Metadata *getRawRetainedTypes() const { return getOperand(5); }
867 Metadata *getRawSubprograms() const { return getOperand(6); }
868 Metadata *getRawGlobalVariables() const { return getOperand(7); }
869 Metadata *getRawImportedEntities() const { return getOperand(8); }
871 /// \brief Replace arrays.
873 /// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
874 /// deleted on a uniquing collision. In practice, uniquing collisions on \a
875 /// MDCompileUnit should be fairly rare.
877 void replaceSubprograms(MDTuple *N) { replaceOperandWith(6, N); }
878 void replaceGlobalVariables(MDTuple *N) { replaceOperandWith(7, N); }
881 static bool classof(const Metadata *MD) {
882 return MD->getMetadataID() == MDCompileUnitKind;
886 /// \brief A scope for locals.
888 /// A legal scope for lexical blocks, local variables, and debug info
889 /// locations. Subclasses are \a MDSubprogram, \a MDLexicalBlock, and \a
890 /// MDLexicalBlockFile.
891 class MDLocalScope : public MDScope {
893 MDLocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
894 ArrayRef<Metadata *> Ops)
895 : MDScope(C, ID, Storage, Tag, Ops) {}
899 static bool classof(const Metadata *MD) {
900 return MD->getMetadataID() == MDSubprogramKind ||
901 MD->getMetadataID() == MDLexicalBlockKind ||
902 MD->getMetadataID() == MDLexicalBlockFileKind;
906 /// \brief Debug location.
908 /// A debug location in source code, used for debug info and otherwise.
909 class MDLocation : public MDNode {
910 friend class LLVMContextImpl;
913 MDLocation(LLVMContext &C, StorageType Storage, unsigned Line,
914 unsigned Column, ArrayRef<Metadata *> MDs);
915 ~MDLocation() { dropAllReferences(); }
917 static MDLocation *getImpl(LLVMContext &Context, unsigned Line,
918 unsigned Column, Metadata *Scope,
919 Metadata *InlinedAt, StorageType Storage,
920 bool ShouldCreate = true);
921 static MDLocation *getImpl(LLVMContext &Context, unsigned Line,
922 unsigned Column, MDLocalScope *Scope,
923 MDLocation *InlinedAt, StorageType Storage,
924 bool ShouldCreate = true) {
925 return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
926 static_cast<Metadata *>(InlinedAt), Storage, ShouldCreate);
929 TempMDLocation cloneImpl() const {
930 return getTemporary(getContext(), getLine(), getColumn(), getScope(),
934 // Disallow replacing operands.
935 void replaceOperandWith(unsigned I, Metadata *New) = delete;
938 DEFINE_MDNODE_GET(MDLocation,
939 (unsigned Line, unsigned Column, Metadata *Scope,
940 Metadata *InlinedAt = nullptr),
941 (Line, Column, Scope, InlinedAt))
942 DEFINE_MDNODE_GET(MDLocation,
943 (unsigned Line, unsigned Column, MDLocalScope *Scope,
944 MDLocation *InlinedAt = nullptr),
945 (Line, Column, Scope, InlinedAt))
947 /// \brief Return a (temporary) clone of this.
948 TempMDLocation clone() const { return cloneImpl(); }
950 unsigned getLine() const { return SubclassData32; }
951 unsigned getColumn() const { return SubclassData16; }
952 MDLocalScope *getScope() const {
953 return cast_or_null<MDLocalScope>(getRawScope());
955 MDLocation *getInlinedAt() const {
956 return cast_or_null<MDLocation>(getRawInlinedAt());
959 Metadata *getRawScope() const { return getOperand(0); }
960 Metadata *getRawInlinedAt() const {
961 if (getNumOperands() == 2)
962 return getOperand(1);
966 static bool classof(const Metadata *MD) {
967 return MD->getMetadataID() == MDLocationKind;
971 /// \brief Subprogram description.
973 /// TODO: Remove DisplayName. It's always equal to Name.
974 /// TODO: Split up flags.
975 class MDSubprogram : public MDLocalScope {
976 friend class LLVMContextImpl;
982 unsigned VirtualIndex;
988 MDSubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
989 unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
990 unsigned Flags, bool IsLocalToUnit, bool IsDefinition,
991 bool IsOptimized, ArrayRef<Metadata *> Ops)
992 : MDLocalScope(C, MDSubprogramKind, Storage, dwarf::DW_TAG_subprogram,
994 Line(Line), ScopeLine(ScopeLine), Virtuality(Virtuality),
995 VirtualIndex(VirtualIndex), Flags(Flags), IsLocalToUnit(IsLocalToUnit),
996 IsDefinition(IsDefinition), IsOptimized(IsOptimized) {}
999 static MDSubprogram *
1000 getImpl(LLVMContext &Context, Metadata *Scope, StringRef Name,
1001 StringRef LinkageName, MDFile *File, unsigned Line,
1002 MDSubroutineType *Type, bool IsLocalToUnit, bool IsDefinition,
1003 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
1004 unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
1005 ConstantAsMetadata *Function, MDTuple *TemplateParams,
1006 MDSubprogram *Declaration, MDTuple *Variables, StorageType Storage,
1007 bool ShouldCreate = true) {
1008 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1009 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1010 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1011 Virtuality, VirtualIndex, Flags, IsOptimized, Function,
1012 TemplateParams, Declaration, Variables, Storage,
1015 static MDSubprogram *
1016 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1017 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1018 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
1019 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
1020 unsigned Flags, bool IsOptimized, Metadata *Function,
1021 Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
1022 StorageType Storage, bool ShouldCreate = true);
1024 TempMDSubprogram cloneImpl() const {
1025 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1026 getFile(), getLine(), getType(), isLocalToUnit(),
1027 isDefinition(), getScopeLine(), getContainingType(),
1028 getVirtuality(), getVirtualIndex(), getFlags(),
1029 isOptimized(), getFunction(), getTemplateParams(),
1030 getDeclaration(), getVariables());
1036 (Metadata * Scope, StringRef Name, StringRef LinkageName, MDFile *File,
1037 unsigned Line, MDSubroutineType *Type, bool IsLocalToUnit,
1038 bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType,
1039 unsigned Virtuality, unsigned VirtualIndex, unsigned Flags,
1040 bool IsOptimized, ConstantAsMetadata *Function = nullptr,
1041 MDTuple *TemplateParams = nullptr, MDSubprogram *Declaration = nullptr,
1042 MDTuple *Variables = nullptr),
1043 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1044 ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized,
1045 Function, TemplateParams, Declaration, Variables))
1048 (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
1049 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
1050 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
1051 unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
1052 Metadata *Function = nullptr, Metadata *TemplateParams = nullptr,
1053 Metadata *Declaration = nullptr, Metadata *Variables = nullptr),
1054 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1055 ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized,
1056 Function, TemplateParams, Declaration, Variables))
1058 TempMDSubprogram clone() const { return cloneImpl(); }
1061 unsigned getLine() const { return Line; }
1062 unsigned getVirtuality() const { return Virtuality; }
1063 unsigned getVirtualIndex() const { return VirtualIndex; }
1064 unsigned getScopeLine() const { return ScopeLine; }
1065 unsigned getFlags() const { return Flags; }
1066 bool isLocalToUnit() const { return IsLocalToUnit; }
1067 bool isDefinition() const { return IsDefinition; }
1068 bool isOptimized() const { return IsOptimized; }
1070 // FIXME: Remove this once MDScope::getFile() does the same.
1071 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
1073 Metadata *getScope() const { return getRawScope(); }
1075 StringRef getName() const { return getStringOperand(2); }
1076 StringRef getDisplayName() const { return getStringOperand(3); }
1077 StringRef getLinkageName() const { return getStringOperand(4); }
1079 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1080 MDString *getRawLinkageName() const { return getOperandAs<MDString>(4); }
1082 MDSubroutineType *getType() const {
1083 return cast_or_null<MDSubroutineType>(getRawType());
1085 Metadata *getContainingType() const { return getRawContainingType(); }
1087 ConstantAsMetadata *getFunction() const {
1088 return cast_or_null<ConstantAsMetadata>(getRawFunction());
1090 MDTuple *getTemplateParams() const {
1091 return cast_or_null<MDTuple>(getRawTemplateParams());
1093 MDSubprogram *getDeclaration() const {
1094 return cast_or_null<MDSubprogram>(getRawDeclaration());
1096 MDTuple *getVariables() const {
1097 return cast_or_null<MDTuple>(getRawVariables());
1100 Metadata *getRawScope() const { return getOperand(1); }
1101 Metadata *getRawType() const { return getOperand(5); }
1102 Metadata *getRawContainingType() const { return getOperand(6); }
1103 Metadata *getRawFunction() const { return getOperand(7); }
1104 Metadata *getRawTemplateParams() const { return getOperand(8); }
1105 Metadata *getRawDeclaration() const { return getOperand(9); }
1106 Metadata *getRawVariables() const { return getOperand(10); }
1108 /// \brief Replace the function.
1110 /// If \a isUniqued() and not \a isResolved(), this could node will be
1111 /// RAUW'ed and deleted out from under the caller. Use a \a TrackingMDRef if
1112 /// that's a problem.
1114 void replaceFunction(Function *F);
1115 void replaceFunction(ConstantAsMetadata *MD) { replaceOperandWith(7, MD); }
1116 void replaceFunction(std::nullptr_t) { replaceOperandWith(7, nullptr); }
1119 static bool classof(const Metadata *MD) {
1120 return MD->getMetadataID() == MDSubprogramKind;
1124 class MDLexicalBlockBase : public MDLocalScope {
1126 MDLexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage,
1127 ArrayRef<Metadata *> Ops)
1128 : MDLocalScope(C, ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
1129 ~MDLexicalBlockBase() {}
1132 // FIXME: Remove this once MDScope::getFile() does the same.
1133 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
1135 MDLocalScope *getScope() const { return cast<MDLocalScope>(getRawScope()); }
1137 Metadata *getRawScope() const { return getOperand(1); }
1139 static bool classof(const Metadata *MD) {
1140 return MD->getMetadataID() == MDLexicalBlockKind ||
1141 MD->getMetadataID() == MDLexicalBlockFileKind;
1145 class MDLexicalBlock : public MDLexicalBlockBase {
1146 friend class LLVMContextImpl;
1147 friend class MDNode;
1152 MDLexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
1153 unsigned Column, ArrayRef<Metadata *> Ops)
1154 : MDLexicalBlockBase(C, MDLexicalBlockKind, Storage, Ops), Line(Line),
1156 ~MDLexicalBlock() {}
1158 static MDLexicalBlock *getImpl(LLVMContext &Context, MDLocalScope *Scope,
1159 MDFile *File, unsigned Line, unsigned Column,
1160 StorageType Storage,
1161 bool ShouldCreate = true) {
1162 return getImpl(Context, static_cast<Metadata *>(Scope),
1163 static_cast<Metadata *>(File), Line, Column, Storage,
1167 static MDLexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
1168 Metadata *File, unsigned Line, unsigned Column,
1169 StorageType Storage, bool ShouldCreate = true);
1171 TempMDLexicalBlock cloneImpl() const {
1172 return getTemporary(getContext(), getScope(), getFile(), getLine(),
1177 DEFINE_MDNODE_GET(MDLexicalBlock, (MDLocalScope * Scope, MDFile *File,
1178 unsigned Line, unsigned Column),
1179 (Scope, File, Line, Column))
1180 DEFINE_MDNODE_GET(MDLexicalBlock, (Metadata * Scope, Metadata *File,
1181 unsigned Line, unsigned Column),
1182 (Scope, File, Line, Column))
1184 TempMDLexicalBlock clone() const { return cloneImpl(); }
1186 unsigned getLine() const { return Line; }
1187 unsigned getColumn() const { return Column; }
1189 static bool classof(const Metadata *MD) {
1190 return MD->getMetadataID() == MDLexicalBlockKind;
1194 class MDLexicalBlockFile : public MDLexicalBlockBase {
1195 friend class LLVMContextImpl;
1196 friend class MDNode;
1198 unsigned Discriminator;
1200 MDLexicalBlockFile(LLVMContext &C, StorageType Storage,
1201 unsigned Discriminator, ArrayRef<Metadata *> Ops)
1202 : MDLexicalBlockBase(C, MDLexicalBlockFileKind, Storage, Ops),
1203 Discriminator(Discriminator) {}
1204 ~MDLexicalBlockFile() {}
1206 static MDLexicalBlockFile *getImpl(LLVMContext &Context, MDLocalScope *Scope,
1207 MDFile *File, unsigned Discriminator,
1208 StorageType Storage,
1209 bool ShouldCreate = true) {
1210 return getImpl(Context, static_cast<Metadata *>(Scope),
1211 static_cast<Metadata *>(File), Discriminator, Storage,
1215 static MDLexicalBlockFile *getImpl(LLVMContext &Context, Metadata *Scope,
1216 Metadata *File, unsigned Discriminator,
1217 StorageType Storage,
1218 bool ShouldCreate = true);
1220 TempMDLexicalBlockFile cloneImpl() const {
1221 return getTemporary(getContext(), getScope(), getFile(),
1222 getDiscriminator());
1226 DEFINE_MDNODE_GET(MDLexicalBlockFile, (MDLocalScope * Scope, MDFile *File,
1227 unsigned Discriminator),
1228 (Scope, File, Discriminator))
1229 DEFINE_MDNODE_GET(MDLexicalBlockFile,
1230 (Metadata * Scope, Metadata *File, unsigned Discriminator),
1231 (Scope, File, Discriminator))
1233 TempMDLexicalBlockFile clone() const { return cloneImpl(); }
1235 unsigned getDiscriminator() const { return Discriminator; }
1237 static bool classof(const Metadata *MD) {
1238 return MD->getMetadataID() == MDLexicalBlockFileKind;
1242 class MDNamespace : public MDScope {
1243 friend class LLVMContextImpl;
1244 friend class MDNode;
1248 MDNamespace(LLVMContext &Context, StorageType Storage, unsigned Line,
1249 ArrayRef<Metadata *> Ops)
1250 : MDScope(Context, MDNamespaceKind, Storage, dwarf::DW_TAG_namespace,
1255 static MDNamespace *getImpl(LLVMContext &Context, Metadata *Scope,
1256 Metadata *File, StringRef Name, unsigned Line,
1257 StorageType Storage, bool ShouldCreate = true) {
1258 return getImpl(Context, Scope, File, getCanonicalMDString(Context, Name),
1259 Line, Storage, ShouldCreate);
1261 static MDNamespace *getImpl(LLVMContext &Context, Metadata *Scope,
1262 Metadata *File, MDString *Name, unsigned Line,
1263 StorageType Storage, bool ShouldCreate = true);
1265 TempMDNamespace cloneImpl() const {
1266 return getTemporary(getContext(), getScope(), getFile(), getName(),
1271 DEFINE_MDNODE_GET(MDNamespace, (Metadata * Scope, Metadata *File,
1272 StringRef Name, unsigned Line),
1273 (Scope, File, Name, Line))
1274 DEFINE_MDNODE_GET(MDNamespace, (Metadata * Scope, Metadata *File,
1275 MDString *Name, unsigned Line),
1276 (Scope, File, Name, Line))
1278 TempMDNamespace clone() const { return cloneImpl(); }
1280 unsigned getLine() const { return Line; }
1281 Metadata *getScope() const { return getOperand(1); }
1282 StringRef getName() const { return getStringOperand(2); }
1284 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1286 static bool classof(const Metadata *MD) {
1287 return MD->getMetadataID() == MDNamespaceKind;
1291 /// \brief Base class for template parameters.
1292 class MDTemplateParameter : public DebugNode {
1294 MDTemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
1295 unsigned Tag, ArrayRef<Metadata *> Ops)
1296 : DebugNode(Context, ID, Storage, Tag, Ops) {}
1297 ~MDTemplateParameter() {}
1300 StringRef getName() const { return getStringOperand(0); }
1301 Metadata *getType() const { return getOperand(1); }
1303 MDString *getRawName() const { return getOperandAs<MDString>(0); }
1305 static bool classof(const Metadata *MD) {
1306 return MD->getMetadataID() == MDTemplateTypeParameterKind ||
1307 MD->getMetadataID() == MDTemplateValueParameterKind;
1311 class MDTemplateTypeParameter : public MDTemplateParameter {
1312 friend class LLVMContextImpl;
1313 friend class MDNode;
1315 MDTemplateTypeParameter(LLVMContext &Context, StorageType Storage,
1316 ArrayRef<Metadata *> Ops)
1317 : MDTemplateParameter(Context, MDTemplateTypeParameterKind, Storage,
1318 dwarf::DW_TAG_template_type_parameter, Ops) {}
1319 ~MDTemplateTypeParameter() {}
1321 static MDTemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
1322 Metadata *Type, StorageType Storage,
1323 bool ShouldCreate = true) {
1324 return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
1327 static MDTemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name,
1328 Metadata *Type, StorageType Storage,
1329 bool ShouldCreate = true);
1331 TempMDTemplateTypeParameter cloneImpl() const {
1332 return getTemporary(getContext(), getName(), getType());
1336 DEFINE_MDNODE_GET(MDTemplateTypeParameter, (StringRef Name, Metadata *Type),
1338 DEFINE_MDNODE_GET(MDTemplateTypeParameter, (MDString * Name, Metadata *Type),
1341 TempMDTemplateTypeParameter clone() const { return cloneImpl(); }
1343 static bool classof(const Metadata *MD) {
1344 return MD->getMetadataID() == MDTemplateTypeParameterKind;
1348 class MDTemplateValueParameter : public MDTemplateParameter {
1349 friend class LLVMContextImpl;
1350 friend class MDNode;
1352 MDTemplateValueParameter(LLVMContext &Context, StorageType Storage,
1353 unsigned Tag, ArrayRef<Metadata *> Ops)
1354 : MDTemplateParameter(Context, MDTemplateValueParameterKind, Storage, Tag,
1356 ~MDTemplateValueParameter() {}
1358 static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
1359 StringRef Name, Metadata *Type,
1360 Metadata *Value, StorageType Storage,
1361 bool ShouldCreate = true) {
1362 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
1363 Value, Storage, ShouldCreate);
1365 static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
1366 MDString *Name, Metadata *Type,
1367 Metadata *Value, StorageType Storage,
1368 bool ShouldCreate = true);
1370 TempMDTemplateValueParameter cloneImpl() const {
1371 return getTemporary(getContext(), getTag(), getName(), getType(),
1376 DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, StringRef Name,
1377 Metadata *Type, Metadata *Value),
1378 (Tag, Name, Type, Value))
1379 DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, MDString *Name,
1380 Metadata *Type, Metadata *Value),
1381 (Tag, Name, Type, Value))
1383 TempMDTemplateValueParameter clone() const { return cloneImpl(); }
1385 Metadata *getValue() const { return getOperand(2); }
1387 static bool classof(const Metadata *MD) {
1388 return MD->getMetadataID() == MDTemplateValueParameterKind;
1392 /// \brief Base class for variables.
1394 /// TODO: Hardcode to DW_TAG_variable.
1395 class MDVariable : public DebugNode {
1399 MDVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
1400 unsigned Line, ArrayRef<Metadata *> Ops)
1401 : DebugNode(C, ID, Storage, Tag, Ops), Line(Line) {}
1405 unsigned getLine() const { return Line; }
1406 MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
1407 StringRef getName() const { return getStringOperand(1); }
1408 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
1409 Metadata *getType() const { return getRawType(); }
1411 Metadata *getRawScope() const { return getOperand(0); }
1412 MDString *getRawName() const { return getOperandAs<MDString>(1); }
1413 Metadata *getRawFile() const { return getOperand(2); }
1414 Metadata *getRawType() const { return getOperand(3); }
1416 static bool classof(const Metadata *MD) {
1417 return MD->getMetadataID() == MDLocalVariableKind ||
1418 MD->getMetadataID() == MDGlobalVariableKind;
1422 /// \brief Global variables.
1424 /// TODO: Remove DisplayName. It's always equal to Name.
1425 class MDGlobalVariable : public MDVariable {
1426 friend class LLVMContextImpl;
1427 friend class MDNode;
1432 MDGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
1433 bool IsLocalToUnit, bool IsDefinition,
1434 ArrayRef<Metadata *> Ops)
1435 : MDVariable(C, MDGlobalVariableKind, Storage, dwarf::DW_TAG_variable,
1437 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
1438 ~MDGlobalVariable() {}
1440 static MDGlobalVariable *
1441 getImpl(LLVMContext &Context, MDScope *Scope, StringRef Name,
1442 StringRef LinkageName, MDFile *File, unsigned Line, Metadata *Type,
1443 bool IsLocalToUnit, bool IsDefinition, ConstantAsMetadata *Variable,
1444 MDDerivedType *StaticDataMemberDeclaration, StorageType Storage,
1445 bool ShouldCreate = true) {
1446 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1447 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1448 IsLocalToUnit, IsDefinition, Variable,
1449 StaticDataMemberDeclaration, Storage, ShouldCreate);
1451 static MDGlobalVariable *
1452 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1453 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1454 bool IsLocalToUnit, bool IsDefinition, Metadata *Variable,
1455 Metadata *StaticDataMemberDeclaration, StorageType Storage,
1456 bool ShouldCreate = true);
1458 TempMDGlobalVariable cloneImpl() const {
1459 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1460 getFile(), getLine(), getType(), isLocalToUnit(),
1461 isDefinition(), getVariable(),
1462 getStaticDataMemberDeclaration());
1466 DEFINE_MDNODE_GET(MDGlobalVariable,
1467 (MDScope * Scope, StringRef Name, StringRef LinkageName,
1468 MDFile *File, unsigned Line, Metadata *Type,
1469 bool IsLocalToUnit, bool IsDefinition,
1470 ConstantAsMetadata *Variable,
1471 MDDerivedType *StaticDataMemberDeclaration),
1472 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1473 IsDefinition, Variable, StaticDataMemberDeclaration))
1474 DEFINE_MDNODE_GET(MDGlobalVariable,
1475 (Metadata * Scope, MDString *Name, MDString *LinkageName,
1476 Metadata *File, unsigned Line, Metadata *Type,
1477 bool IsLocalToUnit, bool IsDefinition, Metadata *Variable,
1478 Metadata *StaticDataMemberDeclaration),
1479 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1480 IsDefinition, Variable, StaticDataMemberDeclaration))
1482 TempMDGlobalVariable clone() const { return cloneImpl(); }
1484 bool isLocalToUnit() const { return IsLocalToUnit; }
1485 bool isDefinition() const { return IsDefinition; }
1486 StringRef getDisplayName() const { return getStringOperand(4); }
1487 StringRef getLinkageName() const { return getStringOperand(5); }
1488 ConstantAsMetadata *getVariable() const {
1489 return cast_or_null<ConstantAsMetadata>(getRawVariable());
1491 MDDerivedType *getStaticDataMemberDeclaration() const {
1492 return cast_or_null<MDDerivedType>(getRawStaticDataMemberDeclaration());
1495 MDString *getRawLinkageName() const { return getOperandAs<MDString>(5); }
1496 Metadata *getRawVariable() const { return getOperand(6); }
1497 Metadata *getRawStaticDataMemberDeclaration() const { return getOperand(7); }
1499 static bool classof(const Metadata *MD) {
1500 return MD->getMetadataID() == MDGlobalVariableKind;
1504 /// \brief Local variable.
1506 /// TODO: Split between arguments and otherwise.
1507 /// TODO: Use \c DW_TAG_variable instead of fake tags.
1508 /// TODO: Split up flags.
1509 class MDLocalVariable : public MDVariable {
1510 friend class LLVMContextImpl;
1511 friend class MDNode;
1516 MDLocalVariable(LLVMContext &C, StorageType Storage, unsigned Tag,
1517 unsigned Line, unsigned Arg, unsigned Flags,
1518 ArrayRef<Metadata *> Ops)
1519 : MDVariable(C, MDLocalVariableKind, Storage, Tag, Line, Ops), Arg(Arg),
1521 ~MDLocalVariable() {}
1523 static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag,
1524 MDScope *Scope, StringRef Name, MDFile *File,
1525 unsigned Line, Metadata *Type, unsigned Arg,
1526 unsigned Flags, MDLocation *InlinedAt,
1527 StorageType Storage,
1528 bool ShouldCreate = true) {
1529 return getImpl(Context, Tag, Scope, getCanonicalMDString(Context, Name),
1530 File, Line, Type, Arg, Flags, InlinedAt, Storage,
1533 static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag,
1534 Metadata *Scope, MDString *Name,
1535 Metadata *File, unsigned Line, Metadata *Type,
1536 unsigned Arg, unsigned Flags,
1537 Metadata *InlinedAt, StorageType Storage,
1538 bool ShouldCreate = true);
1540 TempMDLocalVariable cloneImpl() const {
1541 return getTemporary(getContext(), getTag(), getScope(), getName(),
1542 getFile(), getLine(), getType(), getArg(), getFlags(),
1547 DEFINE_MDNODE_GET(MDLocalVariable,
1548 (unsigned Tag, MDLocalScope *Scope, StringRef Name,
1549 MDFile *File, unsigned Line, Metadata *Type, unsigned Arg,
1550 unsigned Flags, MDLocation *InlinedAt = nullptr),
1551 (Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
1552 DEFINE_MDNODE_GET(MDLocalVariable,
1553 (unsigned Tag, Metadata *Scope, MDString *Name,
1554 Metadata *File, unsigned Line, Metadata *Type,
1555 unsigned Arg, unsigned Flags,
1556 Metadata *InlinedAt = nullptr),
1557 (Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
1559 TempMDLocalVariable clone() const { return cloneImpl(); }
1561 /// \brief Get the local scope for this variable.
1563 /// Variables must be defined in a local scope.
1564 MDLocalScope *getScope() const {
1565 return cast<MDLocalScope>(MDVariable::getScope());
1568 unsigned getArg() const { return Arg; }
1569 unsigned getFlags() const { return Flags; }
1570 MDLocation *getInlinedAt() const {
1571 return cast_or_null<MDLocation>(getRawInlinedAt());
1574 Metadata *getRawInlinedAt() const { return getOperand(4); }
1576 /// \brief Get an inlined version of this variable.
1578 /// Returns a version of this with \a getAlinedAt() set to \c InlinedAt.
1579 MDLocalVariable *withInline(MDLocation *InlinedAt) const {
1580 if (InlinedAt == getInlinedAt())
1581 return const_cast<MDLocalVariable *>(this);
1582 auto Temp = clone();
1583 Temp->replaceOperandWith(4, InlinedAt);
1584 return replaceWithUniqued(std::move(Temp));
1586 MDLocalVariable *withoutInline() const { return withInline(nullptr); }
1588 static bool classof(const Metadata *MD) {
1589 return MD->getMetadataID() == MDLocalVariableKind;
1593 /// \brief DWARF expression.
1595 /// TODO: Co-allocate the expression elements.
1596 /// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
1598 class MDExpression : public MDNode {
1599 friend class LLVMContextImpl;
1600 friend class MDNode;
1602 std::vector<uint64_t> Elements;
1604 MDExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
1605 : MDNode(C, MDExpressionKind, Storage, None),
1606 Elements(Elements.begin(), Elements.end()) {}
1609 static MDExpression *getImpl(LLVMContext &Context,
1610 ArrayRef<uint64_t> Elements, StorageType Storage,
1611 bool ShouldCreate = true);
1613 TempMDExpression cloneImpl() const {
1614 return getTemporary(getContext(), getElements());
1618 DEFINE_MDNODE_GET(MDExpression, (ArrayRef<uint64_t> Elements), (Elements))
1620 TempMDExpression clone() const { return cloneImpl(); }
1622 ArrayRef<uint64_t> getElements() const { return Elements; }
1624 unsigned getNumElements() const { return Elements.size(); }
1625 uint64_t getElement(unsigned I) const {
1626 assert(I < Elements.size() && "Index out of range");
1630 typedef ArrayRef<uint64_t>::iterator element_iterator;
1631 element_iterator elements_begin() const { return getElements().begin(); }
1632 element_iterator elements_end() const { return getElements().end(); }
1634 /// \brief A lightweight wrapper around an expression operand.
1636 /// TODO: Store arguments directly and change \a MDExpression to store a
1642 explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
1644 const uint64_t *get() const { return Op; }
1646 /// \brief Get the operand code.
1647 uint64_t getOp() const { return *Op; }
1649 /// \brief Get an argument to the operand.
1651 /// Never returns the operand itself.
1652 uint64_t getArg(unsigned I) const { return Op[I + 1]; }
1654 unsigned getNumArgs() const { return getSize() - 1; }
1656 /// \brief Return the size of the operand.
1658 /// Return the number of elements in the operand (1 + args).
1659 unsigned getSize() const;
1662 /// \brief An iterator for expression operands.
1663 class expr_op_iterator
1664 : public std::iterator<std::input_iterator_tag, ExprOperand> {
1668 explicit expr_op_iterator(element_iterator I) : Op(I) {}
1670 element_iterator getBase() const { return Op.get(); }
1671 const ExprOperand &operator*() const { return Op; }
1672 const ExprOperand *operator->() const { return &Op; }
1674 expr_op_iterator &operator++() {
1678 expr_op_iterator operator++(int) {
1679 expr_op_iterator T(*this);
1684 bool operator==(const expr_op_iterator &X) const {
1685 return getBase() == X.getBase();
1687 bool operator!=(const expr_op_iterator &X) const {
1688 return getBase() != X.getBase();
1692 void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
1695 /// \brief Visit the elements via ExprOperand wrappers.
1697 /// These range iterators visit elements through \a ExprOperand wrappers.
1698 /// This is not guaranteed to be a valid range unless \a isValid() gives \c
1701 /// \pre \a isValid() gives \c true.
1703 expr_op_iterator expr_op_begin() const {
1704 return expr_op_iterator(elements_begin());
1706 expr_op_iterator expr_op_end() const {
1707 return expr_op_iterator(elements_end());
1711 bool isValid() const;
1713 static bool classof(const Metadata *MD) {
1714 return MD->getMetadataID() == MDExpressionKind;
1718 class MDObjCProperty : public DebugNode {
1719 friend class LLVMContextImpl;
1720 friend class MDNode;
1723 unsigned Attributes;
1725 MDObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
1726 unsigned Attributes, ArrayRef<Metadata *> Ops)
1727 : DebugNode(C, MDObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property,
1729 Line(Line), Attributes(Attributes) {}
1730 ~MDObjCProperty() {}
1732 static MDObjCProperty *
1733 getImpl(LLVMContext &Context, StringRef Name, Metadata *File, unsigned Line,
1734 StringRef GetterName, StringRef SetterName, unsigned Attributes,
1735 Metadata *Type, StorageType Storage, bool ShouldCreate = true) {
1736 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
1737 getCanonicalMDString(Context, GetterName),
1738 getCanonicalMDString(Context, SetterName), Attributes, Type,
1739 Storage, ShouldCreate);
1741 static MDObjCProperty *getImpl(LLVMContext &Context, MDString *Name,
1742 Metadata *File, unsigned Line,
1743 MDString *GetterName, MDString *SetterName,
1744 unsigned Attributes, Metadata *Type,
1745 StorageType Storage, bool ShouldCreate = true);
1747 TempMDObjCProperty cloneImpl() const {
1748 return getTemporary(getContext(), getName(), getFile(), getLine(),
1749 getGetterName(), getSetterName(), getAttributes(),
1754 DEFINE_MDNODE_GET(MDObjCProperty,
1755 (StringRef Name, Metadata *File, unsigned Line,
1756 StringRef GetterName, StringRef SetterName,
1757 unsigned Attributes, Metadata *Type),
1758 (Name, File, Line, GetterName, SetterName, Attributes,
1760 DEFINE_MDNODE_GET(MDObjCProperty,
1761 (MDString * Name, Metadata *File, unsigned Line,
1762 MDString *GetterName, MDString *SetterName,
1763 unsigned Attributes, Metadata *Type),
1764 (Name, File, Line, GetterName, SetterName, Attributes,
1767 TempMDObjCProperty clone() const { return cloneImpl(); }
1769 unsigned getLine() const { return Line; }
1770 unsigned getAttributes() const { return Attributes; }
1771 StringRef getName() const { return getStringOperand(0); }
1772 Metadata *getFile() const { return getOperand(1); }
1773 StringRef getGetterName() const { return getStringOperand(2); }
1774 StringRef getSetterName() const { return getStringOperand(3); }
1775 Metadata *getType() const { return getOperand(4); }
1777 MDString *getRawName() const { return getOperandAs<MDString>(0); }
1778 MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }
1779 MDString *getRawSetterName() const { return getOperandAs<MDString>(3); }
1781 static bool classof(const Metadata *MD) {
1782 return MD->getMetadataID() == MDObjCPropertyKind;
1786 class MDImportedEntity : public DebugNode {
1787 friend class LLVMContextImpl;
1788 friend class MDNode;
1792 MDImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
1793 unsigned Line, ArrayRef<Metadata *> Ops)
1794 : DebugNode(C, MDImportedEntityKind, Storage, Tag, Ops), Line(Line) {}
1795 ~MDImportedEntity() {}
1797 static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
1798 Metadata *Scope, Metadata *Entity,
1799 unsigned Line, StringRef Name,
1800 StorageType Storage,
1801 bool ShouldCreate = true) {
1802 return getImpl(Context, Tag, Scope, Entity, Line,
1803 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
1805 static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
1806 Metadata *Scope, Metadata *Entity,
1807 unsigned Line, MDString *Name,
1808 StorageType Storage,
1809 bool ShouldCreate = true);
1811 TempMDImportedEntity cloneImpl() const {
1812 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
1813 getLine(), getName());
1817 DEFINE_MDNODE_GET(MDImportedEntity,
1818 (unsigned Tag, Metadata *Scope, Metadata *Entity,
1819 unsigned Line, StringRef Name = ""),
1820 (Tag, Scope, Entity, Line, Name))
1821 DEFINE_MDNODE_GET(MDImportedEntity,
1822 (unsigned Tag, Metadata *Scope, Metadata *Entity,
1823 unsigned Line, MDString *Name),
1824 (Tag, Scope, Entity, Line, Name))
1826 TempMDImportedEntity clone() const { return cloneImpl(); }
1828 unsigned getLine() const { return Line; }
1829 Metadata *getScope() const { return getOperand(0); }
1830 Metadata *getEntity() const { return getOperand(1); }
1831 StringRef getName() const { return getStringOperand(2); }
1833 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1835 static bool classof(const Metadata *MD) {
1836 return MD->getMetadataID() == MDImportedEntityKind;
1840 } // end namespace llvm
1842 #undef DEFINE_MDNODE_GET_UNPACK_IMPL
1843 #undef DEFINE_MDNODE_GET_UNPACK
1844 #undef DEFINE_MDNODE_GET