[PATCH] [clang-tidy] Add a checker for zero-length memset.
Benjamin Kramer
benny.kra at gmail.com
Wed Jul 16 07:52:28 PDT 2014
================
Comment at: clang-tidy/google/MemsetZeroLengthCheck.cpp:60
@@ +59,3 @@
+ // Try to evaluate the second argument so we can also find values that are not
+ // just literals. We don't emit a warning if the second argument also
+ // evaluates to zero.
----------------
Alexander Kornienko wrote:
> Maybe we should emit a warning, that this call is a no-op?
Fixed.
================
Comment at: clang-tidy/google/MemsetZeroLengthCheck.cpp:64
@@ +63,3 @@
+ if (!Arg2->EvaluateAsInt(Value2, *Result.Context) || Value2 != 0 ||
+ (Arg1->EvaluateAsInt(Value1, *Result.Context) && Value1 == 0))
+ return;
----------------
Alexander Kornienko wrote:
> I'd say Value1 < 0 is also not when we want to swap the arguments.
That seems like an incredibly weak heuristic. Zero-sized memsets should not occur in real code :(
http://reviews.llvm.org/D4535
More information about the cfe-commits
mailing list