[PATCH] D22968: [analyzer] A checker for macOS-specific bool-like objects.

Anna Zaks via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 10:54:36 PDT 2016


zaks.anna added a comment.

Let's test it on more real word bugs.


================
Comment at: lib/StaticAnalyzer/Checkers/BoolConversionChecker.cpp:11
@@ +10,3 @@
+// This file defines BoolConversionChecker, which checks for a particular
+// common mistake when dealing with NSNumber and OSBoolean objects:
+// When having a pointer P to such object, neither `if (P)' nor `bool X = P'
----------------
Should we warn on comparisons of NSNumber to '0'? Comparisons to 'nil' would be considered a proper pointer comparison, while comparisons to literal '0' would be considered a faulty comparison of the numbers.

================
Comment at: lib/StaticAnalyzer/Checkers/BoolConversionChecker.cpp:49
@@ +48,3 @@
+  virtual void run(const MatchFinder::MatchResult &Result) {
+    // This callback only throws reports. All the logic is in the matchers.
+    const Stmt *Conv = Result.Nodes.getNodeAs<Stmt>("conv");
----------------
"throws" -> "generates"?


https://reviews.llvm.org/D22968





More information about the cfe-commits mailing list