Skip to content

Commit f69b2d3

Browse files
authored
Merge pull request #1905 from goblint/overflow-kind-minus
Distinguish unary and binary minus in overflow messages
2 parents 379b3a1 + 391ce3a commit f69b2d3

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

src/cdomain/value/cdomains/intDomain0.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ let add_overflow_check ~(op:overflow_op) ~underflow ~overflow ik =
8888
let sign = if signed then "Signed" else "Unsigned" in
8989
let op =
9090
match op with
91+
(* explicitly distinguish binary and unary - *)
92+
| Binop (MinusA | MinusPP | MinusPI) -> "binary -" (* only MinusA should probably be possible here *)
93+
| Unop Neg -> "unary -"
9194
| Binop bop -> CilType.Binop.show bop
9295
| Unop uop -> CilType.Unop.show uop
9396
| Cast -> "cast"

tests/regression/29-svcomp/32-no-ov.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
[Info] SV-COMP specification: CHECK( init(main()), LTL(G ! overflow) )
44
[Warning][Integer > Overflow][CWE-190] Unsigned integer overflow in << (32-no-ov.c:5:6-5:159)
55
[Warning][Integer > Overflow][CWE-190] Unsigned integer overflow in << (32-no-ov.c:5:6-5:159)
6-
[Warning][Integer > Overflow][CWE-191] Unsigned integer underflow in - (32-no-ov.c:5:6-5:159)
6+
[Warning][Integer > Overflow][CWE-191] Unsigned integer underflow in unary - (32-no-ov.c:5:6-5:159)
7+
[Warning][Integer > Overflow][CWE-191] Unsigned integer underflow in binary - (32-no-ov.c:5:6-5:159)
78
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in cast (32-no-ov.c:5:6-5:159)
89
[Info][Deadcode] Logical lines of code (LLoC) summary:
910
live: 3

tests/regression/cfg/foo.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
$ goblint --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.invariant-types '["location_invariant", "loop_invariant"]' --set sem.int.signed_overflow assume_none foo.c
6363
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in + (foo.c:4:5-4:8)
64-
[Warning][Integer > Overflow][CWE-191] Signed integer underflow in - (foo.c:5:5-5:8)
64+
[Warning][Integer > Overflow][CWE-191] Signed integer underflow in binary - (foo.c:5:5-5:8)
6565
[Info][Deadcode] Logical lines of code (LLoC) summary:
6666
live: 6
6767
dead: 0

tests/regression/cfg/issue-1356.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393

9494

9595
$ goblint --enable ana.sv-comp.functions --enable ana.int.interval --enable witness.yaml.enabled --set witness.yaml.invariant-types '["location_invariant"]' issue-1356.c
96-
[Warning][Integer > Overflow][CWE-190][CWE-191] Signed integer overflow and underflow in - (issue-1356.c:11:10-11:15)
96+
[Warning][Integer > Overflow][CWE-190][CWE-191] Signed integer overflow and underflow in binary - (issue-1356.c:11:10-11:15)
9797
[Info][Deadcode] Logical lines of code (LLoC) summary:
9898
live: 13
9999
dead: 0

0 commit comments

Comments
 (0)