r230949 - Replace loop with equivalent ArrayRef function. NFC.

David Blaikie dblaikie at gmail.com
Mon Mar 2 12:45:52 PST 2015


On Mon, Mar 2, 2015 at 12:39 PM, Benjamin Kramer <benny.kra at gmail.com>
wrote:

> On Mon, Mar 2, 2015 at 8:32 PM, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> > On Mon, Mar 2, 2015 at 3:57 AM, Benjamin Kramer <
> benny.kra at googlemail.com>
> > wrote:
> >>
> >> Author: d0k
> >> Date: Mon Mar  2 05:57:06 2015
> >> New Revision: 230949
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=230949&view=rev
> >> Log:
> >> Replace loop with equivalent ArrayRef function. NFC.
> >>
> >> Modified:
> >>     cfe/trunk/lib/CodeGen/TargetInfo.cpp
> >>
> >> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=230949&r1=230948&r2=230949&view=diff
> >>
> >>
> ==============================================================================
> >> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Mar  2 05:57:06 2015
> >> @@ -6131,12 +6131,7 @@ private:
> >>
> >>      // Check if Ty is a usable substitute for the coercion type.
> >>      bool isUsableType(llvm::StructType *Ty) const {
> >> -      if (Ty->getNumElements() != Elems.size())
> >> -        return false;
> >> -      for (unsigned i = 0, e = Elems.size(); i != e; ++i)
> >> -        if (Elems[i] != Ty->getElementType(i))
> >> -          return false;
> >> -      return true;
> >> +      return llvm::makeArrayRef(Elems) == Ty->elements();
> >
> >
> > Shouldn't this work without the makeArrayRef call? (the RHS is already an
> > ArrayRef, and the LHS can be implicitly converted to one)
>
> Nope, apparently implicit conversion isn't that aggressive
>
> include/llvm/ADT/ArrayRef.h:329:15: note: candidate template ignored:
> could not match 'ArrayRef' against 'SmallVector'
>

Oh, because templates. :( That's unfortunate. 'spose that'd require
templating the comparison, having two (one for the ArrayRef LHS, one for
ArrayRef on the RHS) & SFINAE'ng on implicit conversion to the respective
ArrayRef. Blah.


>
> - Ben
>
> >
> >>
> >>      }
> >>
> >>      // Get the coercion type as a literal struct type.
> >>
> >>
> >> _______________________________________________
> >> cfe-commits mailing list
> >> cfe-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150302/8ff3a070/attachment.html>


More information about the cfe-commits mailing list