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

Craig Topper craig.topper at gmail.com
Fri May 15 16:43:12 PDT 2015


Oh yeah i don't know why i did the two negations. that was dumb. I'll fix.
I think my brain got messed up around the fact that the original code
didn't even use "empty" it was checking getSize() == 0.

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

> On 16.5.2015 2:10, Pasi Parviainen 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 :(.
>>
>
> And this is meant as a comment for those double negations...
>
>
>
>>        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
>>>
>>>
>>
>


-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150515/e700f994/attachment.html>


More information about the llvm-commits mailing list