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 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
287 /// \brief Return the raw underlying file.
289 /// An \a MDFile is an \a MDScope, but it doesn't point at a separate file
290 /// (it\em is the file). If \c this is an \a MDFile, we need to return \c
291 /// this. Otherwise, return the first operand, which is where all other
292 /// subclasses store their file pointer.
293 Metadata *getRawFile() const {
294 return isa<MDFile>(this) ? const_cast<MDScope *>(this)
295 : static_cast<Metadata *>(getOperand(0));
298 static bool classof(const Metadata *MD) {
299 switch (MD->getMetadataID()) {
302 case MDBasicTypeKind:
303 case MDDerivedTypeKind:
304 case MDCompositeTypeKind:
305 case MDSubroutineTypeKind:
307 case MDCompileUnitKind:
308 case MDSubprogramKind:
309 case MDLexicalBlockKind:
310 case MDLexicalBlockFileKind:
311 case MDNamespaceKind:
319 /// TODO: Merge with directory/file node (including users).
320 /// TODO: Canonicalize paths on creation.
321 class MDFile : public MDScope {
322 friend class LLVMContextImpl;
325 MDFile(LLVMContext &C, StorageType Storage, ArrayRef<Metadata *> Ops)
326 : MDScope(C, MDFileKind, Storage, dwarf::DW_TAG_file_type, Ops) {}
329 static MDFile *getImpl(LLVMContext &Context, StringRef Filename,
330 StringRef Directory, StorageType Storage,
331 bool ShouldCreate = true) {
332 return getImpl(Context, getCanonicalMDString(Context, Filename),
333 getCanonicalMDString(Context, Directory), Storage,
336 static MDFile *getImpl(LLVMContext &Context, MDString *Filename,
337 MDString *Directory, StorageType Storage,
338 bool ShouldCreate = true);
340 TempMDFile cloneImpl() const {
341 return getTemporary(getContext(), getFilename(), getDirectory());
345 DEFINE_MDNODE_GET(MDFile, (StringRef Filename, StringRef Directory),
346 (Filename, Directory))
347 DEFINE_MDNODE_GET(MDFile, (MDString * Filename, MDString *Directory),
348 (Filename, Directory))
350 TempMDFile clone() const { return cloneImpl(); }
352 StringRef getFilename() const { return getStringOperand(0); }
353 StringRef getDirectory() const { return getStringOperand(1); }
355 MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
356 MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
358 static bool classof(const Metadata *MD) {
359 return MD->getMetadataID() == MDFileKind;
363 /// \brief Base class for types.
365 /// TODO: Remove the hardcoded name and context, since many types don't use
367 /// TODO: Split up flags.
368 class MDType : public MDScope {
372 uint64_t AlignInBits;
373 uint64_t OffsetInBits;
376 MDType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
377 unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
378 uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
379 : MDScope(C, ID, Storage, Tag, Ops), Line(Line), Flags(Flags),
380 SizeInBits(SizeInBits), AlignInBits(AlignInBits),
381 OffsetInBits(OffsetInBits) {}
385 TempMDType clone() const {
386 return TempMDType(cast<MDType>(MDNode::clone().release()));
389 unsigned getLine() const { return Line; }
390 uint64_t getSizeInBits() const { return SizeInBits; }
391 uint64_t getAlignInBits() const { return AlignInBits; }
392 uint64_t getOffsetInBits() const { return OffsetInBits; }
393 unsigned getFlags() const { return Flags; }
395 Metadata *getScope() const { return getRawScope(); }
396 StringRef getName() const { return getStringOperand(2); }
399 Metadata *getRawScope() const { return getOperand(1); }
400 MDString *getRawName() const { return getOperandAs<MDString>(2); }
402 void setFlags(unsigned NewFlags) {
403 assert(!isUniqued() && "Cannot set flags on uniqued nodes");
407 static bool classof(const Metadata *MD) {
408 switch (MD->getMetadataID()) {
411 case MDBasicTypeKind:
412 case MDDerivedTypeKind:
413 case MDCompositeTypeKind:
414 case MDSubroutineTypeKind:
420 /// \brief Basic type.
422 /// TODO: Split out DW_TAG_unspecified_type.
423 /// TODO: Drop unused accessors.
424 class MDBasicType : public MDType {
425 friend class LLVMContextImpl;
430 MDBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
431 uint64_t SizeInBits, uint64_t AlignInBits, unsigned Encoding,
432 ArrayRef<Metadata *> Ops)
433 : MDType(C, MDBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
435 Encoding(Encoding) {}
438 static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
439 StringRef Name, uint64_t SizeInBits,
440 uint64_t AlignInBits, unsigned Encoding,
441 StorageType Storage, bool ShouldCreate = true) {
442 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
443 SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate);
445 static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
446 MDString *Name, uint64_t SizeInBits,
447 uint64_t AlignInBits, unsigned Encoding,
448 StorageType Storage, bool ShouldCreate = true);
450 TempMDBasicType cloneImpl() const {
451 return getTemporary(getContext(), getTag(), getName(), getSizeInBits(),
452 getAlignInBits(), getEncoding());
456 DEFINE_MDNODE_GET(MDBasicType, (unsigned Tag, StringRef Name),
457 (Tag, Name, 0, 0, 0))
458 DEFINE_MDNODE_GET(MDBasicType,
459 (unsigned Tag, StringRef Name, uint64_t SizeInBits,
460 uint64_t AlignInBits, unsigned Encoding),
461 (Tag, Name, SizeInBits, AlignInBits, Encoding))
462 DEFINE_MDNODE_GET(MDBasicType,
463 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
464 uint64_t AlignInBits, unsigned Encoding),
465 (Tag, Name, SizeInBits, AlignInBits, Encoding))
467 TempMDBasicType clone() const { return cloneImpl(); }
469 unsigned getEncoding() const { return Encoding; }
471 static bool classof(const Metadata *MD) {
472 return MD->getMetadataID() == MDBasicTypeKind;
476 /// \brief Base class for MDDerivedType and MDCompositeType.
478 /// TODO: Delete; they're not really related.
479 class MDDerivedTypeBase : public MDType {
481 MDDerivedTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
482 unsigned Tag, unsigned Line, uint64_t SizeInBits,
483 uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
484 ArrayRef<Metadata *> Ops)
485 : MDType(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
487 ~MDDerivedTypeBase() {}
490 Metadata *getBaseType() const { return getRawBaseType(); }
491 Metadata *getRawBaseType() const { return getOperand(3); }
493 static bool classof(const Metadata *MD) {
494 return MD->getMetadataID() == MDDerivedTypeKind ||
495 MD->getMetadataID() == MDCompositeTypeKind ||
496 MD->getMetadataID() == MDSubroutineTypeKind;
500 /// \brief Derived types.
502 /// This includes qualified types, pointers, references, friends, typedefs, and
505 /// TODO: Split out members (inheritance, fields, methods, etc.).
506 class MDDerivedType : public MDDerivedTypeBase {
507 friend class LLVMContextImpl;
510 MDDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
511 unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
512 uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
513 : MDDerivedTypeBase(C, MDDerivedTypeKind, Storage, Tag, Line, SizeInBits,
514 AlignInBits, OffsetInBits, Flags, Ops) {}
517 static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
518 StringRef Name, MDFile *File, unsigned Line,
519 Metadata *Scope, Metadata *BaseType,
520 uint64_t SizeInBits, uint64_t AlignInBits,
521 uint64_t OffsetInBits, unsigned Flags,
522 Metadata *ExtraData, StorageType Storage,
523 bool ShouldCreate = true) {
524 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
525 Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
526 Flags, ExtraData, Storage, ShouldCreate);
528 static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
529 MDString *Name, Metadata *File, unsigned Line,
530 Metadata *Scope, Metadata *BaseType,
531 uint64_t SizeInBits, uint64_t AlignInBits,
532 uint64_t OffsetInBits, unsigned Flags,
533 Metadata *ExtraData, StorageType Storage,
534 bool ShouldCreate = true);
536 TempMDDerivedType cloneImpl() const {
537 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
538 getScope(), getBaseType(), getSizeInBits(),
539 getAlignInBits(), getOffsetInBits(), getFlags(),
544 DEFINE_MDNODE_GET(MDDerivedType,
545 (unsigned Tag, MDString *Name, Metadata *File,
546 unsigned Line, Metadata *Scope, Metadata *BaseType,
547 uint64_t SizeInBits, uint64_t AlignInBits,
548 uint64_t OffsetInBits, unsigned Flags,
549 Metadata *ExtraData = nullptr),
550 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
551 AlignInBits, OffsetInBits, Flags, ExtraData))
552 DEFINE_MDNODE_GET(MDDerivedType,
553 (unsigned Tag, StringRef Name, MDFile *File,
554 unsigned Line, Metadata *Scope, Metadata *BaseType,
555 uint64_t SizeInBits, uint64_t AlignInBits,
556 uint64_t OffsetInBits, unsigned Flags,
557 Metadata *ExtraData = nullptr),
558 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
559 AlignInBits, OffsetInBits, Flags, ExtraData))
561 TempMDDerivedType clone() const { return cloneImpl(); }
563 /// \brief Get extra data associated with this derived type.
565 /// Class type for pointer-to-members, objective-c property node for ivars,
566 /// or global constant wrapper for static members.
568 /// TODO: Separate out types that need this extra operand: pointer-to-member
569 /// types and member fields (static members and ivars).
570 Metadata *getExtraData() const { return getRawExtraData(); }
571 Metadata *getRawExtraData() const { return getOperand(4); }
573 static bool classof(const Metadata *MD) {
574 return MD->getMetadataID() == MDDerivedTypeKind;
578 /// \brief Base class for MDCompositeType and MDSubroutineType.
580 /// TODO: Delete; they're not really related.
581 class MDCompositeTypeBase : public MDDerivedTypeBase {
582 unsigned RuntimeLang;
585 MDCompositeTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
586 unsigned Tag, unsigned Line, unsigned RuntimeLang,
587 uint64_t SizeInBits, uint64_t AlignInBits,
588 uint64_t OffsetInBits, unsigned Flags,
589 ArrayRef<Metadata *> Ops)
590 : MDDerivedTypeBase(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits,
591 OffsetInBits, Flags, Ops),
592 RuntimeLang(RuntimeLang) {}
593 ~MDCompositeTypeBase() {}
596 MDTuple *getElements() const {
597 return cast_or_null<MDTuple>(getRawElements());
599 Metadata *getVTableHolder() const { return getRawVTableHolder(); }
600 MDTuple *getTemplateParams() const {
601 return cast_or_null<MDTuple>(getRawTemplateParams());
603 StringRef getIdentifier() const { return getStringOperand(7); }
604 unsigned getRuntimeLang() const { return RuntimeLang; }
606 Metadata *getRawElements() const { return getOperand(4); }
607 Metadata *getRawVTableHolder() const { return getOperand(5); }
608 Metadata *getRawTemplateParams() const { return getOperand(6); }
609 MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
611 /// \brief Replace operands.
613 /// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
614 /// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
615 /// of its movement if necessary.
617 void replaceElements(MDTuple *Elements) {
619 if (auto *Old = cast_or_null<MDTuple>(getElements()))
620 for (const auto &Op : Old->operands())
621 assert(std::find(Elements->op_begin(), Elements->op_end(), Op) &&
622 "Lost a member during member list replacement");
624 replaceOperandWith(4, Elements);
626 void replaceVTableHolder(Metadata *VTableHolder) {
627 replaceOperandWith(5, VTableHolder);
629 void replaceTemplateParams(MDTuple *TemplateParams) {
630 replaceOperandWith(6, TemplateParams);
634 static bool classof(const Metadata *MD) {
635 return MD->getMetadataID() == MDCompositeTypeKind ||
636 MD->getMetadataID() == MDSubroutineTypeKind;
640 /// \brief Composite types.
642 /// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
643 /// TODO: Create a custom, unrelated node for DW_TAG_array_type.
644 class MDCompositeType : public MDCompositeTypeBase {
645 friend class LLVMContextImpl;
648 MDCompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
649 unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
650 uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
651 ArrayRef<Metadata *> Ops)
652 : MDCompositeTypeBase(C, MDCompositeTypeKind, Storage, Tag, Line,
653 RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
655 ~MDCompositeType() {}
657 static MDCompositeType *
658 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
659 unsigned Line, Metadata *Scope, Metadata *BaseType,
660 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
661 uint64_t Flags, Metadata *Elements, unsigned RuntimeLang,
662 Metadata *VTableHolder, Metadata *TemplateParams,
663 StringRef Identifier, StorageType Storage, bool ShouldCreate = true) {
664 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
665 Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
666 Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
667 getCanonicalMDString(Context, Identifier), Storage,
670 static MDCompositeType *
671 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
672 unsigned Line, Metadata *Scope, Metadata *BaseType,
673 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
674 unsigned Flags, Metadata *Elements, unsigned RuntimeLang,
675 Metadata *VTableHolder, Metadata *TemplateParams,
676 MDString *Identifier, StorageType Storage, bool ShouldCreate = true);
678 TempMDCompositeType cloneImpl() const {
679 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
680 getScope(), getBaseType(), getSizeInBits(),
681 getAlignInBits(), getOffsetInBits(), getFlags(),
682 getElements(), getRuntimeLang(), getVTableHolder(),
683 getTemplateParams(), getIdentifier());
687 DEFINE_MDNODE_GET(MDCompositeType,
688 (unsigned Tag, StringRef Name, Metadata *File,
689 unsigned Line, Metadata *Scope, Metadata *BaseType,
690 uint64_t SizeInBits, uint64_t AlignInBits,
691 uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
692 unsigned RuntimeLang, Metadata *VTableHolder,
693 Metadata *TemplateParams = nullptr,
694 StringRef Identifier = ""),
695 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
696 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
697 VTableHolder, TemplateParams, Identifier))
698 DEFINE_MDNODE_GET(MDCompositeType,
699 (unsigned Tag, MDString *Name, Metadata *File,
700 unsigned Line, Metadata *Scope, Metadata *BaseType,
701 uint64_t SizeInBits, uint64_t AlignInBits,
702 uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
703 unsigned RuntimeLang, Metadata *VTableHolder,
704 Metadata *TemplateParams = nullptr,
705 MDString *Identifier = nullptr),
706 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
707 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
708 VTableHolder, TemplateParams, Identifier))
710 TempMDCompositeType clone() const { return cloneImpl(); }
712 static bool classof(const Metadata *MD) {
713 return MD->getMetadataID() == MDCompositeTypeKind;
717 /// \brief Type array for a subprogram.
719 /// TODO: Detach from CompositeType, and fold the array of types in directly
721 class MDSubroutineType : public MDCompositeTypeBase {
722 friend class LLVMContextImpl;
725 MDSubroutineType(LLVMContext &C, StorageType Storage, unsigned Flags,
726 ArrayRef<Metadata *> Ops)
727 : MDCompositeTypeBase(C, MDSubroutineTypeKind, Storage,
728 dwarf::DW_TAG_subroutine_type, 0, 0, 0, 0, 0, Flags,
730 ~MDSubroutineType() {}
732 static MDSubroutineType *getImpl(LLVMContext &Context, unsigned Flags,
733 Metadata *TypeArray, StorageType Storage,
734 bool ShouldCreate = true);
736 TempMDSubroutineType cloneImpl() const {
737 return getTemporary(getContext(), getFlags(), getTypeArray());
741 DEFINE_MDNODE_GET(MDSubroutineType, (unsigned Flags, Metadata *TypeArray),
744 TempMDSubroutineType clone() const { return cloneImpl(); }
746 MDTuple *getTypeArray() const { return getElements(); }
747 Metadata *getRawTypeArray() const { return getRawElements(); }
749 static bool classof(const Metadata *MD) {
750 return MD->getMetadataID() == MDSubroutineTypeKind;
754 /// \brief Compile unit.
755 class MDCompileUnit : public MDScope {
756 friend class LLVMContextImpl;
759 unsigned SourceLanguage;
761 unsigned RuntimeVersion;
762 unsigned EmissionKind;
764 MDCompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
765 bool IsOptimized, unsigned RuntimeVersion,
766 unsigned EmissionKind, ArrayRef<Metadata *> Ops)
767 : MDScope(C, MDCompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
768 SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
769 RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind) {}
772 static MDCompileUnit *
773 getImpl(LLVMContext &Context, unsigned SourceLanguage, MDFile *File,
774 StringRef Producer, bool IsOptimized, StringRef Flags,
775 unsigned RuntimeVersion, StringRef SplitDebugFilename,
776 unsigned EmissionKind, MDTuple *EnumTypes, MDTuple *RetainedTypes,
777 MDTuple *Subprograms, MDTuple *GlobalVariables,
778 MDTuple *ImportedEntities, StorageType Storage,
779 bool ShouldCreate = true) {
780 return getImpl(Context, SourceLanguage, File,
781 getCanonicalMDString(Context, Producer), IsOptimized,
782 getCanonicalMDString(Context, Flags), RuntimeVersion,
783 getCanonicalMDString(Context, SplitDebugFilename),
784 EmissionKind, EnumTypes, RetainedTypes, Subprograms,
785 GlobalVariables, ImportedEntities, Storage, ShouldCreate);
787 static MDCompileUnit *
788 getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
789 MDString *Producer, bool IsOptimized, MDString *Flags,
790 unsigned RuntimeVersion, MDString *SplitDebugFilename,
791 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
792 Metadata *Subprograms, Metadata *GlobalVariables,
793 Metadata *ImportedEntities, StorageType Storage,
794 bool ShouldCreate = true);
796 TempMDCompileUnit cloneImpl() const {
798 getContext(), getSourceLanguage(), getFile(), getProducer(),
799 isOptimized(), getFlags(), getRuntimeVersion(), getSplitDebugFilename(),
800 getEmissionKind(), getEnumTypes(), getRetainedTypes(), getSubprograms(),
801 getGlobalVariables(), getImportedEntities());
805 DEFINE_MDNODE_GET(MDCompileUnit,
806 (unsigned SourceLanguage, MDFile *File, StringRef Producer,
807 bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
808 StringRef SplitDebugFilename, unsigned EmissionKind,
809 MDTuple *EnumTypes, MDTuple *RetainedTypes,
810 MDTuple *Subprograms, MDTuple *GlobalVariables,
811 MDTuple *ImportedEntities),
812 (SourceLanguage, File, Producer, IsOptimized, Flags,
813 RuntimeVersion, SplitDebugFilename, EmissionKind,
814 EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
816 DEFINE_MDNODE_GET(MDCompileUnit,
817 (unsigned SourceLanguage, Metadata *File,
818 MDString *Producer, bool IsOptimized, MDString *Flags,
819 unsigned RuntimeVersion, MDString *SplitDebugFilename,
820 unsigned EmissionKind, Metadata *EnumTypes,
821 Metadata *RetainedTypes, Metadata *Subprograms,
822 Metadata *GlobalVariables, Metadata *ImportedEntities),
823 (SourceLanguage, File, Producer, IsOptimized, Flags,
824 RuntimeVersion, SplitDebugFilename, EmissionKind,
825 EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
828 TempMDCompileUnit clone() const { return cloneImpl(); }
830 unsigned getSourceLanguage() const { return SourceLanguage; }
831 bool isOptimized() const { return IsOptimized; }
832 unsigned getRuntimeVersion() const { return RuntimeVersion; }
833 unsigned getEmissionKind() const { return EmissionKind; }
834 StringRef getProducer() const { return getStringOperand(1); }
835 StringRef getFlags() const { return getStringOperand(2); }
836 StringRef getSplitDebugFilename() const { return getStringOperand(3); }
837 MDTuple *getEnumTypes() const {
838 return cast_or_null<MDTuple>(getRawEnumTypes());
840 MDTuple *getRetainedTypes() const {
841 return cast_or_null<MDTuple>(getRawRetainedTypes());
843 MDTuple *getSubprograms() const {
844 return cast_or_null<MDTuple>(getRawSubprograms());
846 MDTuple *getGlobalVariables() const {
847 return cast_or_null<MDTuple>(getRawGlobalVariables());
849 MDTuple *getImportedEntities() const {
850 return cast_or_null<MDTuple>(getRawImportedEntities());
853 MDString *getRawProducer() const { return getOperandAs<MDString>(1); }
854 MDString *getRawFlags() const { return getOperandAs<MDString>(2); }
855 MDString *getRawSplitDebugFilename() const {
856 return getOperandAs<MDString>(3);
858 Metadata *getRawEnumTypes() const { return getOperand(4); }
859 Metadata *getRawRetainedTypes() const { return getOperand(5); }
860 Metadata *getRawSubprograms() const { return getOperand(6); }
861 Metadata *getRawGlobalVariables() const { return getOperand(7); }
862 Metadata *getRawImportedEntities() const { return getOperand(8); }
864 /// \brief Replace arrays.
866 /// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
867 /// deleted on a uniquing collision. In practice, uniquing collisions on \a
868 /// MDCompileUnit should be fairly rare.
870 void replaceSubprograms(MDTuple *N) { replaceOperandWith(6, N); }
871 void replaceGlobalVariables(MDTuple *N) { replaceOperandWith(7, N); }
874 static bool classof(const Metadata *MD) {
875 return MD->getMetadataID() == MDCompileUnitKind;
879 /// \brief A scope for locals.
881 /// A legal scope for lexical blocks, local variables, and debug info
882 /// locations. Subclasses are \a MDSubprogram, \a MDLexicalBlock, and \a
883 /// MDLexicalBlockFile.
884 class MDLocalScope : public MDScope {
886 MDLocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
887 ArrayRef<Metadata *> Ops)
888 : MDScope(C, ID, Storage, Tag, Ops) {}
892 static bool classof(const Metadata *MD) {
893 return MD->getMetadataID() == MDSubprogramKind ||
894 MD->getMetadataID() == MDLexicalBlockKind ||
895 MD->getMetadataID() == MDLexicalBlockFileKind;
899 /// \brief Debug location.
901 /// A debug location in source code, used for debug info and otherwise.
902 class MDLocation : public MDNode {
903 friend class LLVMContextImpl;
906 MDLocation(LLVMContext &C, StorageType Storage, unsigned Line,
907 unsigned Column, ArrayRef<Metadata *> MDs);
908 ~MDLocation() { dropAllReferences(); }
910 static MDLocation *getImpl(LLVMContext &Context, unsigned Line,
911 unsigned Column, Metadata *Scope,
912 Metadata *InlinedAt, StorageType Storage,
913 bool ShouldCreate = true);
914 static MDLocation *getImpl(LLVMContext &Context, unsigned Line,
915 unsigned Column, MDLocalScope *Scope,
916 MDLocation *InlinedAt, StorageType Storage,
917 bool ShouldCreate = true) {
918 return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
919 static_cast<Metadata *>(InlinedAt), Storage, ShouldCreate);
922 TempMDLocation cloneImpl() const {
923 return getTemporary(getContext(), getLine(), getColumn(), getScope(),
927 // Disallow replacing operands.
928 void replaceOperandWith(unsigned I, Metadata *New) = delete;
931 DEFINE_MDNODE_GET(MDLocation,
932 (unsigned Line, unsigned Column, Metadata *Scope,
933 Metadata *InlinedAt = nullptr),
934 (Line, Column, Scope, InlinedAt))
935 DEFINE_MDNODE_GET(MDLocation,
936 (unsigned Line, unsigned Column, MDLocalScope *Scope,
937 MDLocation *InlinedAt = nullptr),
938 (Line, Column, Scope, InlinedAt))
940 /// \brief Return a (temporary) clone of this.
941 TempMDLocation clone() const { return cloneImpl(); }
943 unsigned getLine() const { return SubclassData32; }
944 unsigned getColumn() const { return SubclassData16; }
945 MDLocalScope *getScope() const {
946 return cast_or_null<MDLocalScope>(getRawScope());
948 MDLocation *getInlinedAt() const {
949 return cast_or_null<MDLocation>(getRawInlinedAt());
952 Metadata *getRawScope() const { return getOperand(0); }
953 Metadata *getRawInlinedAt() const {
954 if (getNumOperands() == 2)
955 return getOperand(1);
959 static bool classof(const Metadata *MD) {
960 return MD->getMetadataID() == MDLocationKind;
964 /// \brief Subprogram description.
966 /// TODO: Remove DisplayName. It's always equal to Name.
967 /// TODO: Split up flags.
968 class MDSubprogram : public MDLocalScope {
969 friend class LLVMContextImpl;
975 unsigned VirtualIndex;
981 MDSubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
982 unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
983 unsigned Flags, bool IsLocalToUnit, bool IsDefinition,
984 bool IsOptimized, ArrayRef<Metadata *> Ops)
985 : MDLocalScope(C, MDSubprogramKind, Storage, dwarf::DW_TAG_subprogram,
987 Line(Line), ScopeLine(ScopeLine), Virtuality(Virtuality),
988 VirtualIndex(VirtualIndex), Flags(Flags), IsLocalToUnit(IsLocalToUnit),
989 IsDefinition(IsDefinition), IsOptimized(IsOptimized) {}
992 static MDSubprogram *
993 getImpl(LLVMContext &Context, Metadata *Scope, StringRef Name,
994 StringRef LinkageName, MDFile *File, unsigned Line,
995 MDSubroutineType *Type, bool IsLocalToUnit, bool IsDefinition,
996 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
997 unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
998 ConstantAsMetadata *Function, MDTuple *TemplateParams,
999 MDSubprogram *Declaration, MDTuple *Variables, StorageType Storage,
1000 bool ShouldCreate = true) {
1001 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1002 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1003 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1004 Virtuality, VirtualIndex, Flags, IsOptimized, Function,
1005 TemplateParams, Declaration, Variables, Storage,
1008 static MDSubprogram *
1009 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1010 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1011 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
1012 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
1013 unsigned Flags, bool IsOptimized, Metadata *Function,
1014 Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
1015 StorageType Storage, bool ShouldCreate = true);
1017 TempMDSubprogram cloneImpl() const {
1018 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1019 getFile(), getLine(), getType(), isLocalToUnit(),
1020 isDefinition(), getScopeLine(), getContainingType(),
1021 getVirtuality(), getVirtualIndex(), getFlags(),
1022 isOptimized(), getFunction(), getTemplateParams(),
1023 getDeclaration(), getVariables());
1029 (Metadata * Scope, StringRef Name, StringRef LinkageName, MDFile *File,
1030 unsigned Line, MDSubroutineType *Type, bool IsLocalToUnit,
1031 bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType,
1032 unsigned Virtuality, unsigned VirtualIndex, unsigned Flags,
1033 bool IsOptimized, ConstantAsMetadata *Function = nullptr,
1034 MDTuple *TemplateParams = nullptr, MDSubprogram *Declaration = nullptr,
1035 MDTuple *Variables = nullptr),
1036 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1037 ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized,
1038 Function, TemplateParams, Declaration, Variables))
1041 (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
1042 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
1043 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
1044 unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
1045 Metadata *Function = nullptr, Metadata *TemplateParams = nullptr,
1046 Metadata *Declaration = nullptr, Metadata *Variables = nullptr),
1047 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1048 ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized,
1049 Function, TemplateParams, Declaration, Variables))
1051 TempMDSubprogram clone() const { return cloneImpl(); }
1054 unsigned getLine() const { return Line; }
1055 unsigned getVirtuality() const { return Virtuality; }
1056 unsigned getVirtualIndex() const { return VirtualIndex; }
1057 unsigned getScopeLine() const { return ScopeLine; }
1058 unsigned getFlags() const { return Flags; }
1059 bool isLocalToUnit() const { return IsLocalToUnit; }
1060 bool isDefinition() const { return IsDefinition; }
1061 bool isOptimized() const { return IsOptimized; }
1063 Metadata *getScope() const { return getRawScope(); }
1065 StringRef getName() const { return getStringOperand(2); }
1066 StringRef getDisplayName() const { return getStringOperand(3); }
1067 StringRef getLinkageName() const { return getStringOperand(4); }
1069 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1070 MDString *getRawLinkageName() const { return getOperandAs<MDString>(4); }
1072 MDSubroutineType *getType() const {
1073 return cast_or_null<MDSubroutineType>(getRawType());
1075 Metadata *getContainingType() const { return getRawContainingType(); }
1077 ConstantAsMetadata *getFunction() const {
1078 return cast_or_null<ConstantAsMetadata>(getRawFunction());
1080 MDTuple *getTemplateParams() const {
1081 return cast_or_null<MDTuple>(getRawTemplateParams());
1083 MDSubprogram *getDeclaration() const {
1084 return cast_or_null<MDSubprogram>(getRawDeclaration());
1086 MDTuple *getVariables() const {
1087 return cast_or_null<MDTuple>(getRawVariables());
1090 Metadata *getRawScope() const { return getOperand(1); }
1091 Metadata *getRawType() const { return getOperand(5); }
1092 Metadata *getRawContainingType() const { return getOperand(6); }
1093 Metadata *getRawFunction() const { return getOperand(7); }
1094 Metadata *getRawTemplateParams() const { return getOperand(8); }
1095 Metadata *getRawDeclaration() const { return getOperand(9); }
1096 Metadata *getRawVariables() const { return getOperand(10); }
1098 /// \brief Replace the function.
1100 /// If \a isUniqued() and not \a isResolved(), this could node will be
1101 /// RAUW'ed and deleted out from under the caller. Use a \a TrackingMDRef if
1102 /// that's a problem.
1104 void replaceFunction(Function *F);
1105 void replaceFunction(ConstantAsMetadata *MD) { replaceOperandWith(7, MD); }
1106 void replaceFunction(std::nullptr_t) { replaceOperandWith(7, nullptr); }
1109 static bool classof(const Metadata *MD) {
1110 return MD->getMetadataID() == MDSubprogramKind;
1114 class MDLexicalBlockBase : public MDLocalScope {
1116 MDLexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage,
1117 ArrayRef<Metadata *> Ops)
1118 : MDLocalScope(C, ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
1119 ~MDLexicalBlockBase() {}
1122 MDLocalScope *getScope() const { return cast<MDLocalScope>(getRawScope()); }
1124 Metadata *getRawScope() const { return getOperand(1); }
1126 static bool classof(const Metadata *MD) {
1127 return MD->getMetadataID() == MDLexicalBlockKind ||
1128 MD->getMetadataID() == MDLexicalBlockFileKind;
1132 class MDLexicalBlock : public MDLexicalBlockBase {
1133 friend class LLVMContextImpl;
1134 friend class MDNode;
1139 MDLexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
1140 unsigned Column, ArrayRef<Metadata *> Ops)
1141 : MDLexicalBlockBase(C, MDLexicalBlockKind, Storage, Ops), Line(Line),
1143 ~MDLexicalBlock() {}
1145 static MDLexicalBlock *getImpl(LLVMContext &Context, MDLocalScope *Scope,
1146 MDFile *File, unsigned Line, unsigned Column,
1147 StorageType Storage,
1148 bool ShouldCreate = true) {
1149 return getImpl(Context, static_cast<Metadata *>(Scope),
1150 static_cast<Metadata *>(File), Line, Column, Storage,
1154 static MDLexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
1155 Metadata *File, unsigned Line, unsigned Column,
1156 StorageType Storage, bool ShouldCreate = true);
1158 TempMDLexicalBlock cloneImpl() const {
1159 return getTemporary(getContext(), getScope(), getFile(), getLine(),
1164 DEFINE_MDNODE_GET(MDLexicalBlock, (MDLocalScope * Scope, MDFile *File,
1165 unsigned Line, unsigned Column),
1166 (Scope, File, Line, Column))
1167 DEFINE_MDNODE_GET(MDLexicalBlock, (Metadata * Scope, Metadata *File,
1168 unsigned Line, unsigned Column),
1169 (Scope, File, Line, Column))
1171 TempMDLexicalBlock clone() const { return cloneImpl(); }
1173 unsigned getLine() const { return Line; }
1174 unsigned getColumn() const { return Column; }
1176 static bool classof(const Metadata *MD) {
1177 return MD->getMetadataID() == MDLexicalBlockKind;
1181 class MDLexicalBlockFile : public MDLexicalBlockBase {
1182 friend class LLVMContextImpl;
1183 friend class MDNode;
1185 unsigned Discriminator;
1187 MDLexicalBlockFile(LLVMContext &C, StorageType Storage,
1188 unsigned Discriminator, ArrayRef<Metadata *> Ops)
1189 : MDLexicalBlockBase(C, MDLexicalBlockFileKind, Storage, Ops),
1190 Discriminator(Discriminator) {}
1191 ~MDLexicalBlockFile() {}
1193 static MDLexicalBlockFile *getImpl(LLVMContext &Context, MDLocalScope *Scope,
1194 MDFile *File, unsigned Discriminator,
1195 StorageType Storage,
1196 bool ShouldCreate = true) {
1197 return getImpl(Context, static_cast<Metadata *>(Scope),
1198 static_cast<Metadata *>(File), Discriminator, Storage,
1202 static MDLexicalBlockFile *getImpl(LLVMContext &Context, Metadata *Scope,
1203 Metadata *File, unsigned Discriminator,
1204 StorageType Storage,
1205 bool ShouldCreate = true);
1207 TempMDLexicalBlockFile cloneImpl() const {
1208 return getTemporary(getContext(), getScope(), getFile(),
1209 getDiscriminator());
1213 DEFINE_MDNODE_GET(MDLexicalBlockFile, (MDLocalScope * Scope, MDFile *File,
1214 unsigned Discriminator),
1215 (Scope, File, Discriminator))
1216 DEFINE_MDNODE_GET(MDLexicalBlockFile,
1217 (Metadata * Scope, Metadata *File, unsigned Discriminator),
1218 (Scope, File, Discriminator))
1220 TempMDLexicalBlockFile clone() const { return cloneImpl(); }
1222 unsigned getDiscriminator() const { return Discriminator; }
1224 static bool classof(const Metadata *MD) {
1225 return MD->getMetadataID() == MDLexicalBlockFileKind;
1229 class MDNamespace : public MDScope {
1230 friend class LLVMContextImpl;
1231 friend class MDNode;
1235 MDNamespace(LLVMContext &Context, StorageType Storage, unsigned Line,
1236 ArrayRef<Metadata *> Ops)
1237 : MDScope(Context, MDNamespaceKind, Storage, dwarf::DW_TAG_namespace,
1242 static MDNamespace *getImpl(LLVMContext &Context, MDScope *Scope,
1243 MDFile *File, StringRef Name, unsigned Line,
1244 StorageType Storage, bool ShouldCreate = true) {
1245 return getImpl(Context, Scope, File, getCanonicalMDString(Context, Name),
1246 Line, Storage, ShouldCreate);
1248 static MDNamespace *getImpl(LLVMContext &Context, Metadata *Scope,
1249 Metadata *File, MDString *Name, unsigned Line,
1250 StorageType Storage, bool ShouldCreate = true);
1252 TempMDNamespace cloneImpl() const {
1253 return getTemporary(getContext(), getScope(), getFile(), getName(),
1258 DEFINE_MDNODE_GET(MDNamespace, (MDScope * Scope, MDFile *File, StringRef Name,
1260 (Scope, File, Name, Line))
1261 DEFINE_MDNODE_GET(MDNamespace, (Metadata * Scope, Metadata *File,
1262 MDString *Name, unsigned Line),
1263 (Scope, File, Name, Line))
1265 TempMDNamespace clone() const { return cloneImpl(); }
1267 unsigned getLine() const { return Line; }
1268 MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
1269 StringRef getName() const { return getStringOperand(2); }
1271 Metadata *getRawScope() const { return getOperand(1); }
1272 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1274 static bool classof(const Metadata *MD) {
1275 return MD->getMetadataID() == MDNamespaceKind;
1279 /// \brief Base class for template parameters.
1280 class MDTemplateParameter : public DebugNode {
1282 MDTemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
1283 unsigned Tag, ArrayRef<Metadata *> Ops)
1284 : DebugNode(Context, ID, Storage, Tag, Ops) {}
1285 ~MDTemplateParameter() {}
1288 StringRef getName() const { return getStringOperand(0); }
1289 Metadata *getType() const { return getOperand(1); }
1291 MDString *getRawName() const { return getOperandAs<MDString>(0); }
1293 static bool classof(const Metadata *MD) {
1294 return MD->getMetadataID() == MDTemplateTypeParameterKind ||
1295 MD->getMetadataID() == MDTemplateValueParameterKind;
1299 class MDTemplateTypeParameter : public MDTemplateParameter {
1300 friend class LLVMContextImpl;
1301 friend class MDNode;
1303 MDTemplateTypeParameter(LLVMContext &Context, StorageType Storage,
1304 ArrayRef<Metadata *> Ops)
1305 : MDTemplateParameter(Context, MDTemplateTypeParameterKind, Storage,
1306 dwarf::DW_TAG_template_type_parameter, Ops) {}
1307 ~MDTemplateTypeParameter() {}
1309 static MDTemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
1310 Metadata *Type, StorageType Storage,
1311 bool ShouldCreate = true) {
1312 return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
1315 static MDTemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name,
1316 Metadata *Type, StorageType Storage,
1317 bool ShouldCreate = true);
1319 TempMDTemplateTypeParameter cloneImpl() const {
1320 return getTemporary(getContext(), getName(), getType());
1324 DEFINE_MDNODE_GET(MDTemplateTypeParameter, (StringRef Name, Metadata *Type),
1326 DEFINE_MDNODE_GET(MDTemplateTypeParameter, (MDString * Name, Metadata *Type),
1329 TempMDTemplateTypeParameter clone() const { return cloneImpl(); }
1331 static bool classof(const Metadata *MD) {
1332 return MD->getMetadataID() == MDTemplateTypeParameterKind;
1336 class MDTemplateValueParameter : public MDTemplateParameter {
1337 friend class LLVMContextImpl;
1338 friend class MDNode;
1340 MDTemplateValueParameter(LLVMContext &Context, StorageType Storage,
1341 unsigned Tag, ArrayRef<Metadata *> Ops)
1342 : MDTemplateParameter(Context, MDTemplateValueParameterKind, Storage, Tag,
1344 ~MDTemplateValueParameter() {}
1346 static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
1347 StringRef Name, Metadata *Type,
1348 Metadata *Value, StorageType Storage,
1349 bool ShouldCreate = true) {
1350 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
1351 Value, Storage, ShouldCreate);
1353 static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
1354 MDString *Name, Metadata *Type,
1355 Metadata *Value, StorageType Storage,
1356 bool ShouldCreate = true);
1358 TempMDTemplateValueParameter cloneImpl() const {
1359 return getTemporary(getContext(), getTag(), getName(), getType(),
1364 DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, StringRef Name,
1365 Metadata *Type, Metadata *Value),
1366 (Tag, Name, Type, Value))
1367 DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, MDString *Name,
1368 Metadata *Type, Metadata *Value),
1369 (Tag, Name, Type, Value))
1371 TempMDTemplateValueParameter clone() const { return cloneImpl(); }
1373 Metadata *getValue() const { return getOperand(2); }
1375 static bool classof(const Metadata *MD) {
1376 return MD->getMetadataID() == MDTemplateValueParameterKind;
1380 /// \brief Base class for variables.
1382 /// TODO: Hardcode to DW_TAG_variable.
1383 class MDVariable : public DebugNode {
1387 MDVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
1388 unsigned Line, ArrayRef<Metadata *> Ops)
1389 : DebugNode(C, ID, Storage, Tag, Ops), Line(Line) {}
1393 unsigned getLine() const { return Line; }
1394 MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
1395 StringRef getName() const { return getStringOperand(1); }
1396 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
1397 Metadata *getType() const { return getRawType(); }
1399 Metadata *getRawScope() const { return getOperand(0); }
1400 MDString *getRawName() const { return getOperandAs<MDString>(1); }
1401 Metadata *getRawFile() const { return getOperand(2); }
1402 Metadata *getRawType() const { return getOperand(3); }
1404 static bool classof(const Metadata *MD) {
1405 return MD->getMetadataID() == MDLocalVariableKind ||
1406 MD->getMetadataID() == MDGlobalVariableKind;
1410 /// \brief Global variables.
1412 /// TODO: Remove DisplayName. It's always equal to Name.
1413 class MDGlobalVariable : public MDVariable {
1414 friend class LLVMContextImpl;
1415 friend class MDNode;
1420 MDGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
1421 bool IsLocalToUnit, bool IsDefinition,
1422 ArrayRef<Metadata *> Ops)
1423 : MDVariable(C, MDGlobalVariableKind, Storage, dwarf::DW_TAG_variable,
1425 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
1426 ~MDGlobalVariable() {}
1428 static MDGlobalVariable *
1429 getImpl(LLVMContext &Context, MDScope *Scope, StringRef Name,
1430 StringRef LinkageName, MDFile *File, unsigned Line, Metadata *Type,
1431 bool IsLocalToUnit, bool IsDefinition, ConstantAsMetadata *Variable,
1432 MDDerivedType *StaticDataMemberDeclaration, StorageType Storage,
1433 bool ShouldCreate = true) {
1434 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1435 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1436 IsLocalToUnit, IsDefinition, Variable,
1437 StaticDataMemberDeclaration, Storage, ShouldCreate);
1439 static MDGlobalVariable *
1440 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1441 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1442 bool IsLocalToUnit, bool IsDefinition, Metadata *Variable,
1443 Metadata *StaticDataMemberDeclaration, StorageType Storage,
1444 bool ShouldCreate = true);
1446 TempMDGlobalVariable cloneImpl() const {
1447 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1448 getFile(), getLine(), getType(), isLocalToUnit(),
1449 isDefinition(), getVariable(),
1450 getStaticDataMemberDeclaration());
1454 DEFINE_MDNODE_GET(MDGlobalVariable,
1455 (MDScope * Scope, StringRef Name, StringRef LinkageName,
1456 MDFile *File, unsigned Line, Metadata *Type,
1457 bool IsLocalToUnit, bool IsDefinition,
1458 ConstantAsMetadata *Variable,
1459 MDDerivedType *StaticDataMemberDeclaration),
1460 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1461 IsDefinition, Variable, StaticDataMemberDeclaration))
1462 DEFINE_MDNODE_GET(MDGlobalVariable,
1463 (Metadata * Scope, MDString *Name, MDString *LinkageName,
1464 Metadata *File, unsigned Line, Metadata *Type,
1465 bool IsLocalToUnit, bool IsDefinition, Metadata *Variable,
1466 Metadata *StaticDataMemberDeclaration),
1467 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1468 IsDefinition, Variable, StaticDataMemberDeclaration))
1470 TempMDGlobalVariable clone() const { return cloneImpl(); }
1472 bool isLocalToUnit() const { return IsLocalToUnit; }
1473 bool isDefinition() const { return IsDefinition; }
1474 StringRef getDisplayName() const { return getStringOperand(4); }
1475 StringRef getLinkageName() const { return getStringOperand(5); }
1476 ConstantAsMetadata *getVariable() const {
1477 return cast_or_null<ConstantAsMetadata>(getRawVariable());
1479 MDDerivedType *getStaticDataMemberDeclaration() const {
1480 return cast_or_null<MDDerivedType>(getRawStaticDataMemberDeclaration());
1483 MDString *getRawLinkageName() const { return getOperandAs<MDString>(5); }
1484 Metadata *getRawVariable() const { return getOperand(6); }
1485 Metadata *getRawStaticDataMemberDeclaration() const { return getOperand(7); }
1487 static bool classof(const Metadata *MD) {
1488 return MD->getMetadataID() == MDGlobalVariableKind;
1492 /// \brief Local variable.
1494 /// TODO: Split between arguments and otherwise.
1495 /// TODO: Use \c DW_TAG_variable instead of fake tags.
1496 /// TODO: Split up flags.
1497 class MDLocalVariable : public MDVariable {
1498 friend class LLVMContextImpl;
1499 friend class MDNode;
1504 MDLocalVariable(LLVMContext &C, StorageType Storage, unsigned Tag,
1505 unsigned Line, unsigned Arg, unsigned Flags,
1506 ArrayRef<Metadata *> Ops)
1507 : MDVariable(C, MDLocalVariableKind, Storage, Tag, Line, Ops), Arg(Arg),
1509 ~MDLocalVariable() {}
1511 static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag,
1512 MDScope *Scope, StringRef Name, MDFile *File,
1513 unsigned Line, Metadata *Type, unsigned Arg,
1514 unsigned Flags, MDLocation *InlinedAt,
1515 StorageType Storage,
1516 bool ShouldCreate = true) {
1517 return getImpl(Context, Tag, Scope, getCanonicalMDString(Context, Name),
1518 File, Line, Type, Arg, Flags, InlinedAt, Storage,
1521 static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag,
1522 Metadata *Scope, MDString *Name,
1523 Metadata *File, unsigned Line, Metadata *Type,
1524 unsigned Arg, unsigned Flags,
1525 Metadata *InlinedAt, StorageType Storage,
1526 bool ShouldCreate = true);
1528 TempMDLocalVariable cloneImpl() const {
1529 return getTemporary(getContext(), getTag(), getScope(), getName(),
1530 getFile(), getLine(), getType(), getArg(), getFlags(),
1535 DEFINE_MDNODE_GET(MDLocalVariable,
1536 (unsigned Tag, MDLocalScope *Scope, StringRef Name,
1537 MDFile *File, unsigned Line, Metadata *Type, unsigned Arg,
1538 unsigned Flags, MDLocation *InlinedAt = nullptr),
1539 (Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
1540 DEFINE_MDNODE_GET(MDLocalVariable,
1541 (unsigned Tag, Metadata *Scope, MDString *Name,
1542 Metadata *File, unsigned Line, Metadata *Type,
1543 unsigned Arg, unsigned Flags,
1544 Metadata *InlinedAt = nullptr),
1545 (Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
1547 TempMDLocalVariable clone() const { return cloneImpl(); }
1549 /// \brief Get the local scope for this variable.
1551 /// Variables must be defined in a local scope.
1552 MDLocalScope *getScope() const {
1553 return cast<MDLocalScope>(MDVariable::getScope());
1556 unsigned getArg() const { return Arg; }
1557 unsigned getFlags() const { return Flags; }
1558 MDLocation *getInlinedAt() const {
1559 return cast_or_null<MDLocation>(getRawInlinedAt());
1562 Metadata *getRawInlinedAt() const { return getOperand(4); }
1564 /// \brief Get an inlined version of this variable.
1566 /// Returns a version of this with \a getAlinedAt() set to \c InlinedAt.
1567 MDLocalVariable *withInline(MDLocation *InlinedAt) const {
1568 if (InlinedAt == getInlinedAt())
1569 return const_cast<MDLocalVariable *>(this);
1570 auto Temp = clone();
1571 Temp->replaceOperandWith(4, InlinedAt);
1572 return replaceWithUniqued(std::move(Temp));
1574 MDLocalVariable *withoutInline() const { return withInline(nullptr); }
1576 static bool classof(const Metadata *MD) {
1577 return MD->getMetadataID() == MDLocalVariableKind;
1581 /// \brief DWARF expression.
1583 /// TODO: Co-allocate the expression elements.
1584 /// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
1586 class MDExpression : public MDNode {
1587 friend class LLVMContextImpl;
1588 friend class MDNode;
1590 std::vector<uint64_t> Elements;
1592 MDExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
1593 : MDNode(C, MDExpressionKind, Storage, None),
1594 Elements(Elements.begin(), Elements.end()) {}
1597 static MDExpression *getImpl(LLVMContext &Context,
1598 ArrayRef<uint64_t> Elements, StorageType Storage,
1599 bool ShouldCreate = true);
1601 TempMDExpression cloneImpl() const {
1602 return getTemporary(getContext(), getElements());
1606 DEFINE_MDNODE_GET(MDExpression, (ArrayRef<uint64_t> Elements), (Elements))
1608 TempMDExpression clone() const { return cloneImpl(); }
1610 ArrayRef<uint64_t> getElements() const { return Elements; }
1612 unsigned getNumElements() const { return Elements.size(); }
1613 uint64_t getElement(unsigned I) const {
1614 assert(I < Elements.size() && "Index out of range");
1618 typedef ArrayRef<uint64_t>::iterator element_iterator;
1619 element_iterator elements_begin() const { return getElements().begin(); }
1620 element_iterator elements_end() const { return getElements().end(); }
1622 /// \brief A lightweight wrapper around an expression operand.
1624 /// TODO: Store arguments directly and change \a MDExpression to store a
1630 explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
1632 const uint64_t *get() const { return Op; }
1634 /// \brief Get the operand code.
1635 uint64_t getOp() const { return *Op; }
1637 /// \brief Get an argument to the operand.
1639 /// Never returns the operand itself.
1640 uint64_t getArg(unsigned I) const { return Op[I + 1]; }
1642 unsigned getNumArgs() const { return getSize() - 1; }
1644 /// \brief Return the size of the operand.
1646 /// Return the number of elements in the operand (1 + args).
1647 unsigned getSize() const;
1650 /// \brief An iterator for expression operands.
1651 class expr_op_iterator
1652 : public std::iterator<std::input_iterator_tag, ExprOperand> {
1656 explicit expr_op_iterator(element_iterator I) : Op(I) {}
1658 element_iterator getBase() const { return Op.get(); }
1659 const ExprOperand &operator*() const { return Op; }
1660 const ExprOperand *operator->() const { return &Op; }
1662 expr_op_iterator &operator++() {
1666 expr_op_iterator operator++(int) {
1667 expr_op_iterator T(*this);
1672 bool operator==(const expr_op_iterator &X) const {
1673 return getBase() == X.getBase();
1675 bool operator!=(const expr_op_iterator &X) const {
1676 return getBase() != X.getBase();
1680 void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
1683 /// \brief Visit the elements via ExprOperand wrappers.
1685 /// These range iterators visit elements through \a ExprOperand wrappers.
1686 /// This is not guaranteed to be a valid range unless \a isValid() gives \c
1689 /// \pre \a isValid() gives \c true.
1691 expr_op_iterator expr_op_begin() const {
1692 return expr_op_iterator(elements_begin());
1694 expr_op_iterator expr_op_end() const {
1695 return expr_op_iterator(elements_end());
1699 bool isValid() const;
1701 static bool classof(const Metadata *MD) {
1702 return MD->getMetadataID() == MDExpressionKind;
1706 class MDObjCProperty : public DebugNode {
1707 friend class LLVMContextImpl;
1708 friend class MDNode;
1711 unsigned Attributes;
1713 MDObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
1714 unsigned Attributes, ArrayRef<Metadata *> Ops)
1715 : DebugNode(C, MDObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property,
1717 Line(Line), Attributes(Attributes) {}
1718 ~MDObjCProperty() {}
1720 static MDObjCProperty *
1721 getImpl(LLVMContext &Context, StringRef Name, MDFile *File, unsigned Line,
1722 StringRef GetterName, StringRef SetterName, unsigned Attributes,
1723 MDType *Type, StorageType Storage, bool ShouldCreate = true) {
1724 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
1725 getCanonicalMDString(Context, GetterName),
1726 getCanonicalMDString(Context, SetterName), Attributes, Type,
1727 Storage, ShouldCreate);
1729 static MDObjCProperty *getImpl(LLVMContext &Context, MDString *Name,
1730 Metadata *File, unsigned Line,
1731 MDString *GetterName, MDString *SetterName,
1732 unsigned Attributes, Metadata *Type,
1733 StorageType Storage, bool ShouldCreate = true);
1735 TempMDObjCProperty cloneImpl() const {
1736 return getTemporary(getContext(), getName(), getFile(), getLine(),
1737 getGetterName(), getSetterName(), getAttributes(),
1742 DEFINE_MDNODE_GET(MDObjCProperty,
1743 (StringRef Name, MDFile *File, unsigned Line,
1744 StringRef GetterName, StringRef SetterName,
1745 unsigned Attributes, MDType *Type),
1746 (Name, File, Line, GetterName, SetterName, Attributes,
1748 DEFINE_MDNODE_GET(MDObjCProperty,
1749 (MDString * Name, Metadata *File, unsigned Line,
1750 MDString *GetterName, MDString *SetterName,
1751 unsigned Attributes, Metadata *Type),
1752 (Name, File, Line, GetterName, SetterName, Attributes,
1755 TempMDObjCProperty clone() const { return cloneImpl(); }
1757 unsigned getLine() const { return Line; }
1758 unsigned getAttributes() const { return Attributes; }
1759 StringRef getName() const { return getStringOperand(0); }
1760 MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
1761 StringRef getGetterName() const { return getStringOperand(2); }
1762 StringRef getSetterName() const { return getStringOperand(3); }
1763 MDType *getType() const { return cast_or_null<MDType>(getRawType()); }
1765 MDString *getRawName() const { return getOperandAs<MDString>(0); }
1766 Metadata *getRawFile() const { return getOperand(1); }
1767 MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }
1768 MDString *getRawSetterName() const { return getOperandAs<MDString>(3); }
1769 Metadata *getRawType() const { return getOperand(4); }
1771 static bool classof(const Metadata *MD) {
1772 return MD->getMetadataID() == MDObjCPropertyKind;
1776 class MDImportedEntity : public DebugNode {
1777 friend class LLVMContextImpl;
1778 friend class MDNode;
1782 MDImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
1783 unsigned Line, ArrayRef<Metadata *> Ops)
1784 : DebugNode(C, MDImportedEntityKind, Storage, Tag, Ops), Line(Line) {}
1785 ~MDImportedEntity() {}
1787 static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
1788 MDScope *Scope, Metadata *Entity,
1789 unsigned Line, StringRef Name,
1790 StorageType Storage,
1791 bool ShouldCreate = true) {
1792 return getImpl(Context, Tag, Scope, Entity, Line,
1793 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
1795 static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
1796 Metadata *Scope, Metadata *Entity,
1797 unsigned Line, MDString *Name,
1798 StorageType Storage,
1799 bool ShouldCreate = true);
1801 TempMDImportedEntity cloneImpl() const {
1802 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
1803 getLine(), getName());
1807 DEFINE_MDNODE_GET(MDImportedEntity,
1808 (unsigned Tag, MDScope *Scope, Metadata *Entity,
1809 unsigned Line, StringRef Name = ""),
1810 (Tag, Scope, Entity, Line, Name))
1811 DEFINE_MDNODE_GET(MDImportedEntity,
1812 (unsigned Tag, Metadata *Scope, Metadata *Entity,
1813 unsigned Line, MDString *Name),
1814 (Tag, Scope, Entity, Line, Name))
1816 TempMDImportedEntity clone() const { return cloneImpl(); }
1818 unsigned getLine() const { return Line; }
1819 MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
1820 Metadata *getEntity() const { return getRawEntity(); }
1821 StringRef getName() const { return getStringOperand(2); }
1823 Metadata *getRawScope() const { return getOperand(0); }
1824 Metadata *getRawEntity() const { return getOperand(1); }
1825 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1827 static bool classof(const Metadata *MD) {
1828 return MD->getMetadataID() == MDImportedEntityKind;
1832 } // end namespace llvm
1834 #undef DEFINE_MDNODE_GET_UNPACK_IMPL
1835 #undef DEFINE_MDNODE_GET_UNPACK
1836 #undef DEFINE_MDNODE_GET