You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/cdomain/value/cdomains/int/bitfieldDomain.ml
+31-11Lines changed: 31 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -624,19 +624,39 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
624
624
625
625
(* Invariant *)
626
626
627
-
letinvariant_ikindeik (z,o) =
628
-
if z =:BArith.one_mask && o =:BArith.one_mask then
629
-
Invariant.top ()
630
-
elseifBArith.is_invalid (z,o) then
631
-
Invariant.none
632
-
else
633
-
letopenGoblintCil.Cilin
627
+
letinvariant_ikindeik (z, o) =
628
+
assert (not (BArith.is_invalid (z, o)));
629
+
letopenGoblintCil.Cilin
630
+
let ik_type =TInt (ik, []) in
631
+
let i1 =
634
632
let def0 = z &: (!: o) in
633
+
if def0 =:BArith.zero_mask then
634
+
Invariant.none
635
+
else (
636
+
let def0 =Ints_t.to_bigint def0 in
637
+
if fitsInInt ik def0 then ( (* At least for _Bool and unsigned types, kintegerCilint can give an incorrect mask if doesn't fit. See https://github.com/goblint/analyzer/pull/1897/changes#r2610251390. *)
638
+
let def0 = kintegerCilint ik def0 in
639
+
Invariant.of_exp (BinOp (Eq, (BinOp (BAnd, e, def0, ik_type)), kintegerCilint ik Z.zero, intType))
640
+
)
641
+
else
642
+
Invariant.none
643
+
)
644
+
in
645
+
let i2 =
635
646
let def1 = o &: (!: z) in
636
-
let (def0, def1) =BatTuple.Tuple2.mapn (kintegerCilint ik) (Ints_t.to_bigint def0, Ints_t.to_bigint def1) in
637
-
let exp0 =Invariant.of_exp (BinOp (Eq, (BinOp (BAnd, (UnOp (BNot, e, TInt(ik,[]))), def0, TInt(ik,[]))), def0, intType)) in
638
-
let exp1 =Invariant.of_exp (BinOp (Eq, (BinOp (BAnd, e, def1, TInt(ik,[]))), def1, intType)) in
639
-
Invariant.meet exp0 exp1
647
+
if def1 =:BArith.zero_mask then
648
+
Invariant.none
649
+
else (
650
+
let def1 =Ints_t.to_bigint def1 in
651
+
if fitsInInt ik def1 then ( (* At least for _Bool and unsigned types, kintegerCilint can give an incorrect mask if doesn't fit. See https://github.com/goblint/analyzer/pull/1897/changes#r2610251390. *)
652
+
let def1 = kintegerCilint ik def1 in
653
+
Invariant.of_exp (BinOp (Eq, (BinOp (BAnd, e, def1, ik_type)), def1, intType))
0 commit comments