[PATCH] D54592: [analyzer][CStringChecker] evaluate explicit_bzero

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 6 16:31:06 PST 2018


NoQ added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:127
   void evalMemset(CheckerContext &C, const CallExpr *CE) const;
+  void evalExplicitBzero(CheckerContext &C, const CallExpr *CE) const;
 
----------------
I guess let's do just `evalBzero`?


================
Comment at: test/Analysis/string.c:1405-1406
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  bzero(str + 2, 2);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{FALSE}}
+}
----------------
Let's also add the true statement. I.e., do we know here that the actual length is 2?


================
Comment at: test/Analysis/string.c:1424
+
+#ifdef SUPPRESS_OUT_OF_BOUND
+void explicit_bzero3_out_ofbound() {
----------------
You can hide `exected-warning`s under `#ifdef`s while leaving the rest of the test intact. Eg.,

```
x = 0;
y = 1 / x;
#ifdef CHECK_DIVIDE_ZERO
// expected-warning at -2{{Division by zero}}
#endif
```

It would be cool to see how this test performs without suppressing out-of-bound warnings.


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

https://reviews.llvm.org/D54592





More information about the cfe-commits mailing list