[PATCH] D43741: [Analyzer] More accurate modeling about the increment operator of the operand with type bool.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 2 14:17:20 PST 2018


NoQ added a comment.

Nice catch, thanks!



================
Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:1078-1080
+    // The use of an operand of type bool with the ++ operators is deprecated
+    // but valid untill C++17. And if the operand of the increment operator is
+    // of type bool, it is set to true untill C++17.
----------------
`untill` seems to be deprecated in favor of `until`.


================
Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:1082
+    if (U->getType()->isBooleanType() && U->isIncrementOp() &&
+        AMgr.getLangOpts().CPlusPlus)
+      Result = svalBuilder.makeTruthVal(true, U->getType());
----------------
Doesn't `isBooleanType()` imply `CPlusPlus`? I guess we need to see if it works in Objective-C++ as well.


================
Comment at: test/Analysis/bool.cpp:65
+    bool b = -10;
+    clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  }
----------------
`dump()` exposes too much internals, we try to only use it for debugging, not for tests.

Would eg. `clang_analyzer_eval(b == 1)` be enough?


Repository:
  rC Clang

https://reviews.llvm.org/D43741





More information about the cfe-commits mailing list