[lld] r196505 - Use !! to convert to a boolean value.

Aaron Ballman aaron at aaronballman.com
Thu Dec 5 11:37:55 PST 2013


FWIW, we already suppress this warning in clang and LLVM. I see no
reason not to do it for lld as well.

~Aaron

On Thu, Dec 5, 2013 at 2:33 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Thu, Dec 5, 2013 at 11:25 AM, Alp Toker <alp at nuanti.com> wrote:
>>
>> On 05/12/2013 18:58, Nick Kledzik wrote:
>>>
>>> On Dec 5, 2013, at 5:11 AM, Rui Ueyama <ruiu at google.com> wrote:
>>>
>>>> Author: ruiu
>>>> Date: Thu Dec  5 07:11:33 2013
>>>> New Revision: 196505
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=196505&view=rev
>>>> Log:
>>>> Use !! to convert to a boolean value.
>>>>
>>>> Modified:
>>>>     lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
>>>>
>>>> Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=196505&r1=196504&r2=196505&view=diff
>>>>
>>>> ==============================================================================
>>>> --- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
>>>> +++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Thu Dec  5
>>>> 07:11:33 2013
>>>> @@ -230,11 +230,7 @@ public:
>>>>      return ArrayRef<uint8_t>(p, p + array.size());
>>>>    }
>>>>
>>>> -  virtual bool hasInputGraph() {
>>>> -    if (_inputGraph)
>>>> -      return true;
>>>> -    return false;
>>>> -  }
>>>> +  virtual bool hasInputGraph() { return !!_inputGraph; }
>>>
>>> This seems rather obtuse.   Why not:
>>>       virtual bool hasInputGraph() { return (_inputGraph != nullptr); }
>>
>>
>> Double bang is a widely used idiom for silencing MSVC C4800, not just for
>> Windows developers but also adopted by various open source projects that
>> need portability to MSVC. Rui's commit was spot on so let's not switch to
>> something less recognisable just for the sake of being different.
>
> I don't actually have a problem with Nick's code either, to be honest
> - I find it less esoteric and more obvious than the !! format. (though
> I'd drop the unnecessary ()s, of course)
>
>> Of course disabling the warning completely and getting MSVC to accept
>> 'normal' code like David Blaikie suggested may be an even better option.
>>
>> Alp.
>>
>>
>>
>>
>>>
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
>> --
>> http://www.nuanti.com
>> the browser experts
>>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list