<div dir="ltr">This patch cause the following compile error on 32 bit android targets:<div><br></div><div><div>/mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp: In member function 'llvm::DICompositeType clang::CodeGen::CGDebugInfo::getOrCreateInstanceMethodType(clang::QualType, const clang::FunctionProtoType*, llvm::DIFile)':</div><div>/mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:1047:22: error: ambiguous overload for 'operator[]' (operand types are 'llvm::DITypeArray {aka llvm::MDTypeRefArray}' and 'int')</div><div>   Elts.push_back(Args[0]);</div><div>                      ^</div><div>/mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:1047:22: note: candidates are:</div><div>/mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:1047:22: note: operator[](llvm::MDTuple*, int) <built-in></div><div>In file included from /mnt/ssd/ll/git/llvm/include/llvm/IR/DebugInfo.h:25:0,</div><div>                 from /mnt/ssd/ll/git/llvm/include/llvm/IR/DIBuilder.h:20,</div><div>                 from /mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.h:23,</div><div>                 from /mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:14:</div><div>/mnt/ssd/ll/git/llvm/include/llvm/IR/DebugInfoMetadata.h:106:13: note: llvm::MDTypeRef llvm::MDTypeRefArray::operator[](unsigned int) const</div><div>   MDTypeRef operator[](unsigned I) const { return MDTypeRef(N->getOperand(I)); }</div></div><div><div><br></div><div>I see two possible fix but I am not sure which one is better:</div><div>* Change the constant in CGDebugInfo.cpp:1047 to unsigned (0u)</div><div>* Change the argument of MDTypeRefArray::operator[] to <span style="color:rgb(0,0,0);font-family:DejaVuSansMono,'DejaVu Sans Mono',courier,monospace;font-size:12.8000001907349px;line-height:15.3600006103516px">std::ptrdiff_t</span> (or something similar)</div><div><br></div><div>I prefer the second option but I am not sure which one is correct so please check it and submit a fix accordingly.</div><div><br></div><div>Thanks,</div><div>Tamas</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 6, 2015 at 9:24 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Apr 6, 2015 at 1:13 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"><div><div><br>
> On 2015-Apr-06, at 12:58, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Mon, Apr 6, 2015 at 12:48 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>> wrote:<br>
> 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>
><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>
<br>
</div></div>I'll keep that in mind.  Here there are no implicit conversions, so I'm<br>
tempted to leave it as is (since this is the most compact/clear way of<br>
writing the code).<br>
<br>
Unless you think this should *always* be the way we do it?</blockquote></div></div><div><br>That's my personal preference, yes - it just hasn't risen to the level of codifying it in the coding standards (like many C++ idioms, really).<br><br>& off-hand I can't find a great/canonical reference on this style/approach. No doubt I read it in a book somewhere... <br><br>Anyway, I'll leave it at "just a thought" rather than make any effort to mandate it, for now.<br><br>- Dave<br> </div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">  If so, you<br>
might propose an addition to the coding standards.  FWIW, I don't have<br>
a strong opinion one way or the other; happy to switch to "the one true<br>
way" if we decide there is one.<br>
<div><div><br>
><br>
> +  };<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" target="_blank">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>
<br>
</div></div></blockquote></span></div><br></div></div>
<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>
<br></blockquote></div><br></div>