<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 6, 2015 at 12:48 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dexonsmith<br>
Date: Mon Apr  6 14:48:50 2015<br>
New Revision: 234200<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=234200&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=234200&view=rev</a><br>
Log:<br>
DebugInfo: Add MDTypeRefArray, to replace DITypeArray<br>
<br>
This array-like wrapper adapts `MDTuple` to have elements of `MDTypeRef`<br>
(whereas `MDTypeArray` has elements of `MDType`).  This is necessary to<br>
migrate code using `DITypeArray`.  The only use of this is<br>
`MDSubroutineType`'s `getTypeArray()` accessor.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/IR/DebugInfoMetadata.h<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234200&r1=234199&r2=234200&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234200&r1=234199&r2=234200&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr  6 14:48:50 2015<br>
@@ -89,6 +89,42 @@ typedef TypedDebugNodeRef<DebugNode> Deb<br>
 typedef TypedDebugNodeRef<MDScope> MDScopeRef;<br>
 typedef TypedDebugNodeRef<MDType> MDTypeRef;<br>
<br>
+class MDTypeRefArray {<br>
+  const MDTuple *N = nullptr;<br>
+<br>
+public:<br>
+  MDTypeRefArray(const MDTuple *N) : N(N) {}<br>
+  operator MDTuple *() const { return const_cast<MDTuple *>(N); }<br>
+  MDTuple *operator->() const { return const_cast<MDTuple *>(N); }<br>
+  MDTuple &operator*() const { return *const_cast<MDTuple *>(N); }<br>
+<br>
+  unsigned size() const { return N->getNumOperands(); }<br>
+  MDTypeRef operator[](unsigned I) const { return MDTypeRef(N->getOperand(I)); }<br>
+<br>
+  class iterator : std::iterator<std::input_iterator_tag, MDTypeRef,<br>
+                                 std::ptrdiff_t, void, MDTypeRef> {<br>
+    MDNode::op_iterator I;<br>
+<br>
+  public:<br>
+    explicit iterator(MDNode::op_iterator I) : I(I) {}<br>
+    MDTypeRef operator*() const { return MDTypeRef(*I); }<br>
+    iterator &operator++() {<br>
+      ++I;<br>
+      return *this;<br>
+    }<br>
+    iterator operator++(int) {<br>
+      iterator Temp(*this);<br>
+      ++I;<br>
+      return Temp;<br>
+    }<br>
+    bool operator==(const iterator &X) const { return I == X.I; }<br>
+    bool operator!=(const iterator &X) const { return I != X.I; }<br></blockquote><div><br>FWIW, ideally op overloads that can be non-members should be (to allow the same conversions on the LHS and RHS) - these could be inline friend definitions (or one a friend, and one not - since it can be defined in terms of the other). Not a big deal & we violate this all over the place, and it's not immediately apparent that any conversions should be possible on either side - just good habits.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  };<br>
+<br>
+  iterator begin() const { return iterator(N->op_begin()); }<br>
+  iterator end() const { return iterator(N->op_end()); }<br>
+};<br>
+<br>
 /// \brief Tagged DWARF-like metadata node.<br>
 ///<br>
 /// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,<br>
@@ -826,7 +862,7 @@ public:<br>
<br>
   TempMDSubroutineType clone() const { return cloneImpl(); }<br>
<br>
-  MDTuple *getTypeArray() const { return getElements(); }<br>
+  MDTypeRefArray getTypeArray() const { return getElements(); }<br>
   Metadata *getRawTypeArray() const { return getRawElements(); }<br>
<br>
   static bool classof(const Metadata *MD) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>