[llvm] r237342 - [TableGen] Simplify some code. NFC

David Blaikie dblaikie at gmail.com
Fri May 15 16:35:12 PDT 2015


On Fri, May 15, 2015 at 4:10 PM, Pasi Parviainen <pasi.parviainen at iki.fi>
wrote:

> On 14.5.2015 8:53, Craig Topper wrote:
>
>> Author: ctopper
>> Date: Thu May 14 00:53:59 2015
>> New Revision: 237342
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=237342&view=rev
>> Log:
>> [TableGen] Simplify some code. NFC
>>
>> Modified:
>>      llvm/trunk/lib/TableGen/Record.cpp
>>
>> Modified: llvm/trunk/lib/TableGen/Record.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=237342&r1=237341&r2=237342&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/TableGen/Record.cpp (original)
>> +++ llvm/trunk/lib/TableGen/Record.cpp Thu May 14 00:53:59 2015
>> @@ -794,14 +794,10 @@ Init *UnOpInit::Fold(Record *CurRec, Mul
>>     }
>>     case EMPTY: {
>>       if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
>> -      if (LHSl->empty())
>> -        return IntInit::get(1);
>> -      return IntInit::get(0);
>> +      return IntInit::get(!!LHSl->empty());
>>       }
>>       if (StringInit *LHSs = dyn_cast<StringInit>(LHS)) {
>> -      if (LHSs->getValue().empty())
>> -        return IntInit::get(1);
>> -      return IntInit::get(0);
>> +      return IntInit::get(!!LHSs->getValue().empty());
>>       }
>>
>
> To which one are you trying to make a point, to a reader or a compiler? If
> for the reader, please don't. And the latter makes me sad :(.


Yeah, doesn't lok like the !! adds anything here - I'd be happy to see
empty passed directly to IntInit::get.


>
>
>        break;
>> @@ -1134,9 +1130,8 @@ Init *TernOpInit::Fold(Record *CurRec, M
>>     }
>>
>>     case FOREACH: {
>> -    Init *Result = ForeachHelper(LHS, MHS, RHS, getType(),
>> -                                 CurRec, CurMultiClass);
>> -    if (Result)
>> +    if (Init *Result = ForeachHelper(LHS, MHS, RHS, getType(),
>> +                                     CurRec, CurMultiClass))
>>         return Result;
>>       break;
>>     }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150515/533f3b09/attachment.html>


More information about the llvm-commits mailing list