]> granicus.if.org Git - clang/commit
[analyzer] Fix wrong comparison generation of the ranges generated by the refutation...
authorMikhail R. Gadelha <mikhail.ramalho@gmail.com>
Thu, 28 Jun 2018 21:26:52 +0000 (21:26 +0000)
committerMikhail R. Gadelha <mikhail.ramalho@gmail.com>
Thu, 28 Jun 2018 21:26:52 +0000 (21:26 +0000)
commit8b67bbb0952f6661deea1b2dad51a41519544522
tree6f64a4ca5491253e63d85bdcf877e8cba9657820
parentff6b0ecacdfc5a066f35b140db832b02082f9731
[analyzer] Fix wrong comparison generation of the ranges generated by the refutation manager

The refutation manager is removing a true bug from the test in this patch.

The problem is that the following constraint:
```
(conj_$1{struct o *}) - (reg_$3<int * r>): [-9223372036854775808, 0]
```
is encoded as:
```
(and (bvuge (bvsub $1 $3) #x8000000000000000)
     (bvule (bvsub $1 $3) #x0000000000000000))
```
The issue is that unsigned comparisons (bvuge and bvule) are being generated instead of signed comparisons (bvsge and bvsle).

When generating the expressions:
```
(conj_$1{p *}) - (reg_$3<int * r>) >= -9223372036854775808
```
and
```
(conj_$1{p *}) - (reg_$3<int * r>) <= 0
```
both -9223372036854775808 and 0 are casted to pointer type and `LTy->isSignedIntegerOrEnumerationType()` in `Z3ConstraintManager::getZ3BinExpr` only checks if the type is signed, not if it's a pointer.

Reviewers: NoQ, george.karpenkov, ddcc

Subscribers: rnkovacs, NoQ, george.karpenkov, ddcc, xazax.hun, szepet, a.sidorin

Differential Revision: https://reviews.llvm.org/D48324

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335926 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
test/PR37855.c [new file with mode: 0644]