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

Aleksei Sidorin via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 17 09:26:35 PST 2015


a.sidorin added inline comments.

================
Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:44
@@ +43,3 @@
+
+    const BinaryOperator *B = dyn_cast<BinaryOperator>(Parent);
+    if (!B)
----------------
Note that InitExprs of DeclStmts are not binary operators. So you will not get a warning on initialization and this test:

```
void test(unsigned int p) {
  unsigned X = 1000;
  unsigned char uc = X; // expected-warning {{Loss of precision}}
}
```
will fail.


http://reviews.llvm.org/D13126





More information about the cfe-commits mailing list