[PATCH] new check checking comparing of boolean expressions and literals

Per Viberg Per.Viberg at evidente.se
Fri Oct 25 08:27:19 PDT 2013


Hi,

Haven't received any comments, thus resending a patch from last week. Is anyone reviewing it?. it would be highly appreciated.

Best regards,
Per



.......................................................................................................................

Hello,

The patch adds a check that warns for relational comparison of boolean expressions with literals 1 and 0.
example:

bool x;
int i,e,y;

if(x > 1){}
if(!i < 0){}
if(1 > (e<y)){}

generates warning:
"relational comparison of boolean expression against literal value '1' or '0' "

see test files bool-compare.c and bool-compare.cpp for more details.


Best regards,
Per

.......................................................................................................................
Per Viberg Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
Phone:    +46 (0)8 402 79 00
Mobile:    +46 (0)70 912 42 52
E-mail:     Per.Viberg at evidente.se

www.evidente.se
This e-mail, which might contain confidential information, is addressed to the above stated person/company. If you are not the correct addressee, employee or in any other way the person concerned, please notify the sender immediately. At the same time, please delete this e-mail and destroy any prints. Thank You.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: relationalCompare_rev3_7.diff
Type: text/x-patch
Size: 16711 bytes
Desc: relationalCompare_rev3_7.diff
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131025/1419a4c5/attachment.bin>


More information about the cfe-commits mailing list