Skip to content

Commit 26b9cad

Browse files
committed
Change ana.base.limit-string-addresses to ana.base.strings.domain
1 parent 12a22b6 commit 26b9cad

File tree

10 files changed

+43
-29
lines changed

10 files changed

+43
-29
lines changed

conf/examples/very-precise.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
"structs" : {
6262
"domain" : "combined-sk"
6363
},
64-
"limit-string-addresses": false
64+
"strings": {
65+
"domain": "disjoint"
66+
}
6567
}
6668
},
6769
"exp": {

src/cdomains/addressDomain_intf.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ sig
7171
- Each {!Addr}, modulo precise index expressions in the offset, is a sublattice with ordering induced by {!Mval}.
7272
- {!NullPtr} is a singleton sublattice.
7373
- {!UnknownPtr} is a singleton sublattice.
74-
- If [ana.base.limit-string-addresses] is enabled, then all {!StrPtr} are together in one sublattice with flat ordering. If [ana.base.limit-string-addresses] is disabled, then each {!StrPtr} is a singleton sublattice. *)
74+
- If [ana.base.strings.domain] is disjoint, then each {!StrPtr} is a singleton sublattice. Otherwise, all {!StrPtr} are together in one sublattice with flat ordering. *)
7575
module AddressLattice (Mval: Mval.Lattice):
7676
sig
7777
include module type of AddressPrintable (Mval)

src/cdomains/stringDomain.ml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
type t = string option [@@deriving eq, ord, hash]
22

33
let hash x =
4-
if GobConfig.get_bool "ana.base.limit-string-addresses" then
5-
13859
6-
else
4+
if GobConfig.get_string "ana.base.strings.domain" = "disjoint" then
75
hash x
6+
else
7+
13859
88

99
let show = function
1010
| Some x -> "\"" ^ x ^ "\""
@@ -17,7 +17,11 @@ include Printable.SimpleShow (
1717
end
1818
)
1919

20-
let of_string x = Some x
20+
let of_string x =
21+
if GobConfig.get_string "ana.base.strings.domain" = "unit" then
22+
None
23+
else
24+
Some x
2125
let to_string x = x
2226

2327
(* only keep part before first null byte *)
@@ -66,24 +70,24 @@ let join x y =
6670
| _, None -> None
6771
| Some a, Some b when a = b -> Some a
6872
| Some a, Some b (* when a <> b *) ->
69-
if GobConfig.get_bool "ana.base.limit-string-addresses" then
70-
None
71-
else
73+
if GobConfig.get_string "ana.base.strings.domain" = "disjoint" then
7274
raise Lattice.Uncomparable
75+
else
76+
None
7377

7478
let meet x y =
7579
match x, y with
7680
| None, a
7781
| a, None -> a
7882
| Some a, Some b when a = b -> Some a
7983
| Some a, Some b (* when a <> b *) ->
80-
if GobConfig.get_bool "ana.base.limit-string-addresses" then
81-
raise Lattice.BotValue
82-
else
84+
if GobConfig.get_string "ana.base.strings.domain" = "disjoint" then
8385
raise Lattice.Uncomparable
86+
else
87+
raise Lattice.BotValue
8488

8589
let repr x =
86-
if GobConfig.get_bool "ana.base.limit-string-addresses" then
87-
None (* all strings together if limited *)
88-
else
90+
if GobConfig.get_string "ana.base.strings.domain" = "disjoint" then
8991
x (* everything else is kept separate, including strings if not limited *)
92+
else
93+
None (* all strings together if limited *)

src/util/options.schema.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,19 @@
619619
},
620620
"additionalProperties": false
621621
},
622-
"limit-string-addresses": {
623-
"title": "ana.base.limit-string-addresses",
624-
"description": "Limit abstract address sets to keep at most one distinct string pointer.",
625-
"type": "boolean",
626-
"default": true
622+
"strings": {
623+
"title": "ana.base.strings",
624+
"type": "object",
625+
"properties": {
626+
"domain": {
627+
"title": "ana.base.strings.domain",
628+
"description": "Domain for string literals.",
629+
"type": "string",
630+
"enum": ["unit", "flat", "disjoint"],
631+
"default": "flat"
632+
}
633+
},
634+
"additionalProperties": false
627635
},
628636
"partition-arrays": {
629637
"title": "ana.base.partition-arrays",

tests/regression/02-base/88-string-ptrs-limited.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//PARAM: --enable ana.base.limit-string-addresses
1+
//PARAM: --set ana.base.strings.domain flat
22
#include <stdlib.h>
33
#include <goblint.h>
44

tests/regression/02-base/89-string-ptrs-not-limited.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//PARAM: --disable ana.base.limit-string-addresses
1+
//PARAM: --set ana.base.strings.domain disjoint
22
#include <stdlib.h>
33
#include <goblint.h>
44

tests/regression/73-strings/01-string_literals.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --disable ana.base.limit-string-addresses --enable ana.int.interval
1+
// PARAM: --set ana.base.strings.domain disjoint --enable ana.int.interval
22

33
#include <goblint.h>
44
#include <string.h>
@@ -21,7 +21,7 @@ int main() {
2121
char* s1 = "abcde";
2222
char* s2 = "abcdfg";
2323
char* s3 = hello_world();
24-
24+
2525
int i = strlen(s1);
2626
__goblint_check(i == 5);
2727

@@ -96,10 +96,10 @@ int main() {
9696
#define STRNCAT strncat(s1, "hi", 1)
9797
#endif
9898
STRNCAT; // WARN
99-
99+
100100
#ifdef __APPLE__
101101
// do nothing => no warning
102-
#else
102+
#else
103103
char s4[] = "hello";
104104
strcpy(s4, s2); // NOWARN
105105
strncpy(s4, s3, 2); // NOWARN

tests/regression/73-strings/02-string_literals_with_null.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --disable ana.base.limit-string-addresses --enable ana.int.interval
1+
// PARAM: --set ana.base.strings.domain disjoint --enable ana.int.interval
22

33
#include <goblint.h>
44
#include <string.h>

tests/regression/73-strings/03-string_basics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --disable ana.base.limit-string-addresses --enable ana.int.interval
1+
// PARAM: --set ana.base.strings.domain disjoint --enable ana.int.interval
22

33
#include <goblint.h>
44
#include <string.h>

tests/regression/73-strings/05-string-unit-domain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.base.limit-string-addresses
1+
// PARAM: --set ana.base.strings.domain unit
22
#include <string.h>
33
#include <goblint.h>
44

0 commit comments

Comments
 (0)