r232999 - Refactor: Simplify boolean expresssions in lib/Lex
David Blaikie
dblaikie at gmail.com
Mon Mar 23 12:57:25 PDT 2015
On Mon, Mar 23, 2015 at 12:49 PM, Richard Smith <richard at metafoo.co.uk>
wrote:
> On Mon, Mar 23, 2015 at 12:39 PM, David Blaikie <dblaikie at gmail.com>
> wrote:
>
>> Author: dblaikie
>> Date: Mon Mar 23 14:39:19 2015
>> New Revision: 232999
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=232999&view=rev
>> Log:
>> Refactor: Simplify boolean expresssions in lib/Lex
>>
>> Simplify boolean expressions using `true` and `false` with `clang-tidy`
>>
>> Patch by Richard Thomson.
>>
>> Differential Revision: http://reviews.llvm.org/D8531
>>
>> Modified:
>> cfe/trunk/lib/Lex/LiteralSupport.cpp
>>
>> Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=232999&r1=232998&r2=232999&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
>> +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Mon Mar 23 14:39:19 2015
>> @@ -144,7 +144,7 @@ static unsigned ProcessCharEscape(const
>> int CharVal = llvm::hexDigitValue(ThisTokBuf[0]);
>> if (CharVal == -1) break;
>> // About to shift out a digit?
>> - Overflow |= (ResultChar & 0xF0000000) ? true : false;
>> + Overflow |= ResultChar & 0xF0000000;
>>
>
> Is this actually simpler? This line now reads like it's conditionally
> setting bits 28-31 of Overflow, whereas previously it was clear that
> Overflow is a bool without needing any additional context. I think
>
> if (ResultChar & 0xF0000000) Overflow = true;
>
> is better than either the old or new code.
>
Agreed - r233006
>
> ResultChar <<= 4;
>> ResultChar |= CharVal;
>> }
>>
>>
>> _______________________________________________
>> 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/20150323/a3d7faf0/attachment.html>
More information about the cfe-commits
mailing list