[cfe-commits] [PATCH v2] Enhance -Wtautological-compare
Xi Wang
xi.wang at gmail.com
Tue Mar 6 07:20:25 PST 2012
Ping?
The most recent patch is attached. Please review. Thanks. ;-)
This patch enhances Clang to catch tautological comparisons
such as (uchar < 0) and (uchar == -1), which are often logic
bugs that break the error handling.
docs/ReleaseNotes.html | 3 +-
include/clang/Basic/DiagnosticSemaKinds.td | 7 +--
lib/Sema/SemaChecking.cpp | 95 +++++++++++++++-----------
test/Sema/compare.c | 23 +++++--
test/SemaTemplate/instantiate-function-1.cpp | 2 +-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmp.patch
Type: application/octet-stream
Size: 11001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120306/35ebf76b/attachment.obj>
-------------- next part --------------
On Mar 2, 2012, at 1:45 AM, Xi Wang wrote:
> Attached is a v2 that incorporates comments from Richard. A unified
> function is used for checking trivial signed/unsigned comparisons.
>
> - xi
>
> On Feb 29, 2012, at 11:36 AM, Xi Wang wrote:
>
>> Clang doesn't issue warnings against tautological comparisons like
>> (uchar < 0) and (uchar == -1). Such tautological comparisons are
>> often logic bugs that break the error handling. Below are some
>> recent examples.
>>
>> http://git.kernel.org/linus/3a7f8fb1
>> http://git.kernel.org/linus/589665f5
>> http://git.kernel.org/linus/4690c33d
>>
>> This patch enhances Clang to catch such tautological comparisons,
>> where bool/uchar/ushort is sign-extended to signed int. Clang
>> currently only warns against unsigned tautological comparisons.
>
> <scmp2.patch>
>
More information about the cfe-commits
mailing list