Skip to content

Commit 6bd7861

Browse files
emit only non-negative refinementconstraints
1 parent 54595bd commit 6bd7861

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/cdomains/apron/linearTwoVarEqualityDomain.apron.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,13 +715,19 @@ struct
715715
| None -> []
716716
| Some d ->
717717
let constyp = Tcons1.get_typ tcons in
718-
let match_compa = if constyp = SUP then Gt else Ge in
718+
(* coff*var_index + cst match_compa 0 -> cil-exp*)
719719
let mkconstraint coff index cst =
720+
let match_compa = match constyp with
721+
| SUPEQ when coff=Z.minus_one -> Le
722+
| SUP when coff=Z.minus_one -> Lt
723+
| SUPEQ when coff=Z.one -> Ge
724+
| SUP when coff=Z.one -> Gt
725+
| _ -> raise (Invalid_argument "refine_value_domains: not implemented") in
720726
let varifo = Option.get @@ V.to_cil_varinfo (Environment.var_of_dim t.env index) in
721727
let ik = Cilfacade.get_ikind (varifo.vtype) in
722728
let lval = Lval (Var varifo, NoOffset) in
723-
let monom = BinOp (Mult,Cil.kintegerCilint ik coff,lval,TInt (ik,[])) in
724-
BinOp (match_compa, monom ,Cil.kintegerCilint ik cst,Cil.intType)
729+
let monom = lval in
730+
BinOp (match_compa, monom ,Cil.kintegerCilint ik Z.(coff*cst),Cil.intType)
725731
in
726732
match simplified_monomials_from_texp t (Texpr1.to_expr @@ Tcons1.get_texpr1 tcons) with
727733
| None -> []
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//SKIP PARAM: --enable ana.int.interval --set sem.int.signed_overflow assume_none
2+
// motivated from SVCOMP's terminator_02-1.c
3+
// checks, whether the lin2var interval refinement meddles with the wrong bounds
4+
5+
#include <goblint.h>
6+
7+
int main()
8+
{
9+
int x;
10+
if(x<100)
11+
{
12+
x=x;
13+
}
14+
__goblint_check(x<100); //UNKNOWN
15+
__goblint_check(x>=-2147483647); //FAIL
16+
return 0;
17+
}
18+
19+

0 commit comments

Comments
 (0)