<div dir="ltr">Thanks for the fix!<div><br></div><div>This seems like a very safe warning from a distance, so I too hope that it won't fire. I'll let you know how it goes.</div><div><br></div><div>If you're very curious, <a href="https://ci.chromium.org/p/chromium/g/chromium.clang/console">https://ci.chromium.org/p/chromium/g/chromium.clang/console</a> are our bots that build trunk clang and then chromium with it.</div><div><br></div><div>(Currently the LLLVM build is broken with gcc5.3 host compilers apparently, hence lots of red.)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 3, 2019 at 11:26 AM Dávid Bolvanský <<a href="mailto:david.bolvansky@gmail.com">david.bolvansky@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Fixed. I manually svncommited only specific files since I have other<br>
changes and forgot to add that file too.<br>
Sorry. Please evaluate this on Chromium. Since ~bool is always true, I<br>
dont think we are gonna have any false positives..<br>
<br>
št 3. 10. 2019 o 17:23 Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>> napísal(a):<br>
><br>
> ../../clang/lib/Sema/SemaExpr.cpp:13481:25: error: no member named 'warn_bitwise_negation_bool' in namespace 'clang::diag'<br>
> Diag(OpLoc, diag::warn_bitwise_negation_bool)<br>
> ~~~~~~^<br>
> 1 error generated.<br>
><br>
> On Thu, Oct 3, 2019 at 11:16 AM David Bolvansky via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> Author: xbolva00<br>
>> Date: Thu Oct 3 08:17:59 2019<br>
>> New Revision: 373614<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=373614&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=373614&view=rev</a><br>
>> Log:<br>
>> [Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with -Wbool-operation<br>
>><br>
>> Requested here:<br>
>> <a href="http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html</a><br>
>><br>
>><br>
>> Added:<br>
>> cfe/trunk/test/Sema/warn-bitwise-negation-bool.c<br>
>> Modified:<br>
>> cfe/trunk/lib/Sema/SemaExpr.cpp<br>
>><br>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=373614&r1=373613&r2=373614&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=373614&r1=373613&r2=373614&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct 3 08:17:59 2019<br>
>> @@ -13470,7 +13470,6 @@ ExprResult Sema::CreateBuiltinUnaryOp(So<br>
>> if (Input.isInvalid())<br>
>> return ExprError();<br>
>> resultType = Input.get()->getType();<br>
>> -<br>
>> if (resultType->isDependentType())<br>
>> break;<br>
>> // C99 6.5.3.3p1. We allow complex int and float as a GCC extension.<br>
>> @@ -13478,6 +13477,9 @@ ExprResult Sema::CreateBuiltinUnaryOp(So<br>
>> // C99 does not support '~' for complex conjugation.<br>
>> Diag(OpLoc, diag::ext_integer_complement_complex)<br>
>> << resultType << Input.get()->getSourceRange();<br>
>> + else if (Input.get()->IgnoreParenImpCasts()->getType()->isBooleanType())<br>
>> + Diag(OpLoc, diag::warn_bitwise_negation_bool)<br>
>> + << FixItHint::CreateReplacement(OpLoc, "!");<br>
>> else if (resultType->hasIntegerRepresentation())<br>
>> break;<br>
>> else if (resultType->isExtVectorType() && Context.getLangOpts().OpenCL) {<br>
>><br>
>> Added: cfe/trunk/test/Sema/warn-bitwise-negation-bool.c<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-bitwise-negation-bool.c?rev=373614&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-bitwise-negation-bool.c?rev=373614&view=auto</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Sema/warn-bitwise-negation-bool.c (added)<br>
>> +++ cfe/trunk/test/Sema/warn-bitwise-negation-bool.c Thu Oct 3 08:17:59 2019<br>
>> @@ -0,0 +1,20 @@<br>
>> +// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wbool-operation %s<br>
>> +// RUN: %clang_cc1 -x c -fsyntax-only -verify %s<br>
>> +// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s<br>
>> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wbool-operation %s<br>
>> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s<br>
>> +// RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s<br>
>> +<br>
>> +#ifdef __cplusplus<br>
>> +typedef bool boolean;<br>
>> +#else<br>
>> +typedef _Bool boolean;<br>
>> +#endif<br>
>> +<br>
>> +void test(boolean b, int i) {<br>
>> + b = ~b; // expected-warning {{bitwise negation of a boolean expression always evaluates to 'true'}}<br>
>> + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"<br>
>> + b = ~(b); // expected-warning {{bitwise negation of a boolean expression always evaluates to 'true'}}<br>
>> + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"<br>
>> + b = ~i;<br>
>> +}<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>