[PATCH] [clang-tidy] Add a checker for zero-length memset.

Alexander Kornienko alexfh at google.com
Wed Jul 16 07:40:04 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.
----------------
Maybe we should emit a warning, that this call is a no-op?

================
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;
----------------
I'd say Value1 < 0 is also not when we want to swap the arguments.

http://reviews.llvm.org/D4535






More information about the cfe-commits mailing list