diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-06 19:48:50 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-06 19:48:50 +0000 |
commit | 62e93623548b0eed5be7a5aa3b49b09a1d775604 (patch) | |
tree | d0b483060c535b816b607b496a32fa76260fc12f | |
parent | 0fbf5aa2052981a084e4e494751c365030cd7ecf (diff) | |
download | bcm5719-llvm-62e93623548b0eed5be7a5aa3b49b09a1d775604.tar.gz bcm5719-llvm-62e93623548b0eed5be7a5aa3b49b09a1d775604.zip |
DebugInfo: Add MDTypeRefArray, to replace DITypeArray
This array-like wrapper adapts `MDTuple` to have elements of `MDTypeRef`
(whereas `MDTypeArray` has elements of `MDType`). This is necessary to
migrate code using `DITypeArray`. The only use of this is
`MDSubroutineType`'s `getTypeArray()` accessor.
llvm-svn: 234200
-rw-r--r-- | llvm/include/llvm/IR/DebugInfoMetadata.h | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 4149bd42438..d162f957701 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -89,6 +89,42 @@ typedef TypedDebugNodeRef<DebugNode> DebugNodeRef; typedef TypedDebugNodeRef<MDScope> MDScopeRef; typedef TypedDebugNodeRef<MDType> MDTypeRef; +class MDTypeRefArray { + const MDTuple *N = nullptr; + +public: + MDTypeRefArray(const MDTuple *N) : N(N) {} + operator MDTuple *() const { return const_cast<MDTuple *>(N); } + MDTuple *operator->() const { return const_cast<MDTuple *>(N); } + MDTuple &operator*() const { return *const_cast<MDTuple *>(N); } + + unsigned size() const { return N->getNumOperands(); } + MDTypeRef operator[](unsigned I) const { return MDTypeRef(N->getOperand(I)); } + + class iterator : std::iterator<std::input_iterator_tag, MDTypeRef, + std::ptrdiff_t, void, MDTypeRef> { + MDNode::op_iterator I; + + public: + explicit iterator(MDNode::op_iterator I) : I(I) {} + MDTypeRef operator*() const { return MDTypeRef(*I); } + iterator &operator++() { + ++I; + return *this; + } + iterator operator++(int) { + iterator Temp(*this); + ++I; + return Temp; + } + bool operator==(const iterator &X) const { return I == X.I; } + bool operator!=(const iterator &X) const { return I != X.I; } + }; + + iterator begin() const { return iterator(N->op_begin()); } + iterator end() const { return iterator(N->op_end()); } +}; + /// \brief Tagged DWARF-like metadata node. /// /// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*, @@ -826,7 +862,7 @@ public: TempMDSubroutineType clone() const { return cloneImpl(); } - MDTuple *getTypeArray() const { return getElements(); } + MDTypeRefArray getTypeArray() const { return getElements(); } Metadata *getRawTypeArray() const { return getRawElements(); } static bool classof(const Metadata *MD) { |