r230949 - Replace loop with equivalent ArrayRef function. NFC.

Benjamin Kramer benny.kra at gmail.com
Mon Mar 2 12:39:17 PST 2015


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'

- 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
>
>



More information about the cfe-commits mailing list