[PATCH] D13126: New static analyzer checker for loss of sign/precision

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 06:00:37 PDT 2016


danielmarjamaki added inline comments.

================
Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:84
@@ +83,3 @@
+// Can E value be greater or equal than Val?
+static bool canBeGreaterEqual(CheckerContext &C, const Expr *E,
+                              unsigned long long Val) {
----------------
zaks.anna wrote:
> This function returns true if the value "is" greater or equal, not "can be" greater or equal. The latter would be "return StGE".
> 
> Also, it's slightly better to return the StGE state and use it to report the bug. This way, our assumption is explicitly recorded in the error state.
NoQ made the same comment. I disagree.

    int A = 0;
    if (X) {
         A = 1000;
    }
    U8 = A;  // <- Imho; A _can_ be 1000

Imho it's better to say that A _can_ be 1000 unless A is 1000 for all possible execution paths through the code.

Do you still think "is" is better than "can be"?


http://reviews.llvm.org/D13126





More information about the cfe-commits mailing list