[PATCH] Warn on suspicious use of absolute value function
Richard Trieu
rtrieu at google.com
Tue Nov 19 18:08:20 PST 2013
This is a new warning to detect improper uses of the absolute value function. Three new warnings are introduced with this patch.
1) Attempting to take the absolute value of an unsigned integer. Includes fix-it to remove the absolute value function call.
2) Using an absolute value function that is too small. For instance, using abs(int) on a long would give a warning and a fix-it to use labs.
3) Using the wrong type of absolute value (integer, floating point, complex) for the argument given. Includes a fix-it to the proper absolute value type.
I have already run this over a large code base and found hundreds of questionable usages of absolute value.
http://llvm-reviews.chandlerc.com/D2224
Files:
test/Sema/warn-absolute-value.c
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/DiagnosticGroups.td
include/clang/Sema/Sema.h
include/clang/AST/Decl.h
lib/Sema/SemaChecking.cpp
lib/AST/Decl.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2224.1.patch
Type: text/x-patch
Size: 59376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131119/0610254a/attachment.bin>
More information about the cfe-commits
mailing list