Skip to content

Commit 3cb651f

Browse files
committed
Add StringDomain interface
1 parent 26b9cad commit 3cb651f

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

src/cdomains/addressDomain_intf.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sig
77
| Addr of Mval.t (** Pointer to mvalue. *)
88
| NullPtr (** NULL pointer. *)
99
| UnknownPtr (** Unknown pointer. Could point to globals, heap and escaped variables. *)
10-
| StrPtr of string option (** String literal pointer. [StrPtr None] abstracts any string pointer *)
10+
| StrPtr of StringDomain.t (** String literal pointer. [StrPtr None] abstracts any string pointer *)
1111
include Printable.S with type t := t (** @closed *)
1212

1313
val of_string: string -> t
@@ -16,8 +16,6 @@ sig
1616
val to_string: t -> string option
1717
(** Convert {!StrPtr} to string if possible. *)
1818

19-
(** C strings are different from OCaml strings as they are not processed after the first [NUL] byte, even though the OCaml string (and a C string literal) may be longer. *)
20-
2119
val to_c_string: t -> string option
2220
(** Convert {!StrPtr} to C string if possible. *)
2321

src/cdomains/stringDomain.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
include Printable.StdLeaf
2+
3+
let name () = "string"
4+
15
type t = string option [@@deriving eq, ord, hash]
26

37
let hash x =

src/cdomains/stringDomain.mli

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(** String literals domain. *)
2+
3+
include Printable.S
4+
5+
val of_string: string -> t
6+
(** Convert from string. *)
7+
8+
val to_string: t -> string option
9+
(** Convert to string if possible. *)
10+
11+
(** C strings are different from OCaml strings as they are not processed after the first [NUL] byte, even though the OCaml string (and a C string literal) may be longer. *)
12+
13+
val to_c_string: t -> string option
14+
(** Convert to C string if possible. *)
15+
16+
val to_n_c_string: int -> t -> string option
17+
(** Convert to C string of given maximum length if possible. *)
18+
19+
val to_string_length: t -> int option
20+
(** Find length of C string if possible. *)
21+
22+
val to_exp: t -> GoblintCil.exp
23+
(** Convert to CIL expression. *)
24+
25+
val semantic_equal: t -> t -> bool option
26+
(** Check semantic equality of two strings.
27+
28+
@return [Some true] if definitely equal, [Some false] if definitely not equal, [None] if unknown. *)
29+
30+
(** Some {!Lattice.S} operations. *)
31+
32+
val leq: t -> t -> bool
33+
val join: t -> t -> t
34+
val meet: t -> t -> t
35+
36+
val repr : t -> t
37+
(** Representative for address lattice. *)

src/goblint_lib.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ module FloatDomain = FloatDomain
211211

212212
module Mval = Mval
213213
module Offset = Offset
214+
module StringDomain = StringDomain
214215
module AddressDomain = AddressDomain
215216

216217
(** {5 Complex} *)

0 commit comments

Comments
 (0)