<div dir="ltr">No problem, thanks for sending me the commit id fixed the issue. It is working now but I would still consider to change the signature of MDTypeRefArray::operator[] to take an std::ptrdiff_t if you don't see any issue what can be caused by it because that one is the standard argument for operator[] and it will eliminate any similar problem in the future.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 7, 2015 at 4:50 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"><span class=""><br>
> On 2015-Apr-07, at 06:59, Tamas Berghammer <<a href="mailto:tberghammer@google.com">tberghammer@google.com</a>> wrote:<br>
><br>
> This patch cause the following compile error on 32 bit android targets:<br>
><br>
> /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)':<br>
> /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')<br>
>    Elts.push_back(Args[0]);<br>
>                       ^<br>
> /mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:1047:22: note: candidates are:<br>
> /mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:1047:22: note: operator[](llvm::MDTuple*, int) <built-in><br>
> In file included from /mnt/ssd/ll/git/llvm/include/llvm/IR/DebugInfo.h:25:0,<br>
>                  from /mnt/ssd/ll/git/llvm/include/llvm/IR/DIBuilder.h:20,<br>
>                  from /mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.h:23,<br>
>                  from /mnt/ssd/ll/git/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:14:<br>
> /mnt/ssd/ll/git/llvm/include/llvm/IR/DebugInfoMetadata.h:106:13: note: llvm::MDTypeRef llvm::MDTypeRefArray::operator[](unsigned int) const<br>
>    MDTypeRef operator[](unsigned I) const { return MDTypeRef(N->getOperand(I)); }<br>
><br>
> I see two possible fix but I am not sure which one is better:<br>
> * Change the constant in CGDebugInfo.cpp:1047 to unsigned (0u)<br>
> * Change the argument of MDTypeRefArray::operator[] to std::ptrdiff_t (or something similar)<br>
><br>
> I prefer the second option but I am not sure which one is correct so please check it and submit a fix accordingly.<br>
><br>
<br>
</span>Looks like Timur applied a bandaid for me in r234307 already.<br>
<br>
Sorry for the trouble!<br>
<div class="HOEnZb"><div class="h5"><br>
> Thanks,<br>
> Tamas<br>
><br>
> On Mon, Apr 6, 2015 at 9:24 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
> On Mon, Apr 6, 2015 at 1:13 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br>
><br>
> > On 2015-Apr-06, at 12:58, David Blaikie <<a href="mailto:dblaikie@gmail.com">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">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>
> 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?<br>
><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>
><br>
>   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>
><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">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>
><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>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>