[PATCH] D54592: [CStringChecker] evaluate explicit_bzero

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 4 10:57:50 PST 2018


NoQ edited reviewers, added: NoQ; removed: dergachev.a.
NoQ added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2206-2207
+  // See if the size argument is zero.
+  const LocationContext *LCtx = C.getLocationContext();
+  SVal SizeVal = State->getSVal(Size, LCtx);
+  QualType SizeTy = Size->getType();
----------------
Modernize a bit: `SVal SizeVal = C.getSVal(Size)`.


================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2214-2220
+  // Get the value of the memory area.
+  SVal MemVal = State->getSVal(Mem, LCtx);
+  
+  // If the size is zero, there won't be any actual memory access,
+  // In this case we just return.
+  if (StateZeroSize && !StateNonZeroSize)
+    return;
----------------
Let's flip these two. We don't need `MemVal` if we are about to return.


================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2215
+  // Get the value of the memory area.
+  SVal MemVal = State->getSVal(Mem, LCtx);
+  
----------------
Modernize that as well and drop the `LCtx` variable.


================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2231
+    return;
+}
+
----------------
Why not finally finish this off with `memsetAux()` to actually zero out the memory?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54592/new/

https://reviews.llvm.org/D54592





More information about the cfe-commits mailing list