Skip to content

Commit 372a838

Browse files
committed
Remove Lattice.Unsupported
All cases can be replaced with BotValue or TopValue.
1 parent 39686d5 commit 372a838

File tree

6 files changed

+15
-21
lines changed

6 files changed

+15
-21
lines changed

src/cdomain/value/cdomains/stringDomain.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let to_string_length x =
7272

7373
let to_exp = function
7474
| Some x -> GoblintCil.mkString x
75-
| None -> raise (Lattice.Unsupported "Cannot express unknown string pointer as expression.")
75+
| None -> failwith "Cannot express unknown string pointer as expression."
7676

7777
let semantic_equal x y =
7878
match x, y with

src/cdomains/stackDomain.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ struct
1313
let n = 3
1414
let rec times x = function 0 -> [] | n -> x::times x (n-1)
1515
let rec map2 f xs ys =
16-
match xs, ys with x::xs, y::ys -> (try f x y :: map2 f xs ys with Lattice.Unsupported _ -> []) | _ -> []
16+
match xs, ys with x::xs, y::ys -> (try f x y :: map2 f xs ys with Lattice.BotValue | Lattice.TopValue -> []) | _ -> []
1717

1818
let rec fold_left2 f a b xs ys =
1919
match xs, ys with
2020
| [], _ | _, [] -> a
2121
| x::xs, y::ys ->
2222
try fold_left2 f (f a x y) b xs ys with
23-
| Lattice.Unsupported _ -> b
23+
| Lattice.BotValue | Lattice.TopValue -> b
2424

2525
let rec take n xs =
2626
match n, xs with

src/domain/lattice.ml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ exception BotValue
4545
(** Exception raised by a bottomless lattice in place of a bottom value.
4646
Surrounding lattice functors may handle this on their own. *)
4747

48-
exception Unsupported of string
49-
let unsupported x = raise (Unsupported x)
50-
5148
exception Invalid_widen of Pretty.doc
5249

5350
let () = Printexc.register_printer (function
@@ -93,10 +90,10 @@ struct
9390
include Base
9491
let leq = equal
9592
let join x y =
96-
if equal x y then x else raise (Unsupported "fake join") (* TODO: TopValue? *)
93+
if equal x y then x else raise TopValue
9794
let widen = join
9895
let meet x y =
99-
if equal x y then x else raise (Unsupported "fake meet") (* TODO: BotValue? *)
96+
if equal x y then x else raise BotValue
10097
let narrow = meet
10198
include NoBotTop
10299

@@ -394,11 +391,11 @@ struct
394391
| (x, `Bot) -> x
395392
| (`Lifted1 x, `Lifted1 y) -> begin
396393
try `Lifted1 (Base1.join x y)
397-
with Unsupported _ | TopValue -> `Top
394+
with TopValue -> `Top
398395
end
399396
| (`Lifted2 x, `Lifted2 y) -> begin
400397
try `Lifted2 (Base2.join x y)
401-
with Unsupported _ | TopValue -> `Top
398+
with TopValue -> `Top
402399
end
403400
| _ -> `Top
404401

@@ -410,11 +407,11 @@ struct
410407
| (x, `Top) -> x
411408
| (`Lifted1 x, `Lifted1 y) -> begin
412409
try `Lifted1 (Base1.meet x y)
413-
with Unsupported _ | BotValue -> `Bot
410+
with BotValue -> `Bot
414411
end
415412
| (`Lifted2 x, `Lifted2 y) -> begin
416413
try `Lifted2 (Base2.meet x y)
417-
with Unsupported _ | BotValue -> `Bot
414+
with BotValue -> `Bot
418415
end
419416
| _ -> `Bot
420417

@@ -581,10 +578,7 @@ end
581578
module Liszt (Base: S) =
582579
struct
583580
include Printable.Liszt (Base)
584-
let bot () = raise (Unsupported "bot?")
585-
let is_top _ = false
586-
let top () = raise (Unsupported "top?")
587-
let is_bot _ = false
581+
include NoBotTop
588582

589583
let leq =
590584
let f acc x y = Base.leq x y && acc in

src/domain/mapDomain.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ struct
398398
let leq = leq_with_fct Range.leq
399399

400400
let find x m = try find x m with | Not_found -> Range.bot ()
401-
let top () = Lattice.unsupported "partial map top"
401+
let top () = raise Lattice.TopValue
402402
let bot () = empty ()
403403
let is_top _ = false
404404
let is_bot = is_empty
@@ -448,7 +448,7 @@ struct
448448

449449
let find x m = try find x m with | Not_found -> Range.top ()
450450
let top () = empty ()
451-
let bot () = Lattice.unsupported "partial map bot"
451+
let bot () = raise Lattice.BotValue
452452
let is_top = is_empty
453453
let is_bot _ = false
454454

src/domains/domainProperties.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct
126126
with
127127
| Failure _ (* raised by IntDomain *)
128128
| SetDomain.Unsupported _ (* raised by SetDomain *)
129-
| Lattice.Unsupported _ (* raised by MapDomain *) ->
129+
| Lattice.TopValue (* raised by MapDomain *) ->
130130
false
131131

132132
let top_leq = make ~name:"top leq" (arb) (fun a ->

tests/unit/domains/mapDomainTest.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct
1818
let get_empty () =
1919
try
2020
(is_empty_top := true; M.top ())
21-
with Lattice.Unsupported _ | Lattice.BotValue | Lattice.TopValue ->
21+
with Lattice.TopValue ->
2222
(is_empty_top := false; M.bot ())
2323

2424
let is_empty x =
@@ -44,7 +44,7 @@ struct
4444
map := M.remove "key1" !map;
4545
begin
4646
try ignore (M.find "key1" !map); assert_failure "problem removeing key1"
47-
with Lattice.Unsupported _ | Lattice.BotValue | Lattice.TopValue -> ()
47+
with Lattice.BotValue | Lattice.TopValue -> ()
4848
end ;
4949

5050
end

0 commit comments

Comments
 (0)