Skip to content

Commit 52a3bbb

Browse files
authored
Merge pull request #1728 from goblint/lattice-lift-po
Weaken `Lattice.Lift{,2}Conf` arguments, remove `Lattice.LiftPO`
2 parents 48ad3e3 + 30ccf69 commit 52a3bbb

File tree

3 files changed

+8
-77
lines changed

3 files changed

+8
-77
lines changed

src/analyses/mCPRegistry.ml

+1-6
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ struct
381381
end
382382

383383
module DomVariantLattice0 (DLSpec : DomainListLatticeSpec)
384-
: Lattice.S with type t = int * Obj.t
384+
: Lattice.PO with type t = int * Obj.t
385385
=
386386
struct
387387
open DLSpec
@@ -403,11 +403,6 @@ struct
403403

404404
let leq = binop_map' (fun _ (module S : Lattice.S) x y -> S.leq (Obj.obj x) (Obj.obj y))
405405

406-
let is_top x = false
407-
let is_bot x = false
408-
let top () = failwith "DomVariantLattice0.top"
409-
let bot () = failwith "DomVariantLattice0.bot"
410-
411406
let pretty_diff () (x, y) =
412407
let f _ (module S : Lattice.S) x y =
413408
if S.leq (Obj.obj x) (Obj.obj y) then nil

src/cdomain/value/cdomains/intDomain0.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ end
841841

842842
module Lift (Base: IkindUnawareS): IkindUnawareS with type t = [ `Bot | `Lifted of Base.t | `Top ] and type int_t = Base.int_t = (* identical to Flat, but does not go to `Top/Bot` if Base raises Unknown/Error *)
843843
struct
844-
include Lattice.LiftPO (struct
844+
include Lattice.LiftConf (struct
845845
include Printable.DefaultConf
846846
let top_name = "MaxInt"
847847
let bot_name = "MinInt"

src/domain/lattice.ml

+6-70
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ end
239239
module Flat = FlatConf (Printable.DefaultConf)
240240

241241

242-
module LiftConf (Conf: Printable.LiftConf) (Base: S) =
242+
module LiftConf (Conf: Printable.LiftConf) (Base: PO) =
243243
struct
244244
include Printable.LiftConf (Conf) (Base)
245245

@@ -270,7 +270,7 @@ struct
270270
| (x, `Bot) -> x
271271
| (`Lifted x, `Lifted y) ->
272272
try `Lifted (Base.join x y)
273-
with TopValue -> `Top
273+
with TopValue | Uncomparable -> `Top
274274

275275
let meet x y =
276276
match (x,y) with
@@ -280,14 +280,14 @@ struct
280280
| (x, `Top) -> x
281281
| (`Lifted x, `Lifted y) ->
282282
try `Lifted (Base.meet x y)
283-
with BotValue -> `Bot
283+
with BotValue | Uncomparable -> `Bot
284284

285285
let widen x y =
286286
match (x,y) with
287287
| (`Lifted x, `Lifted y) ->
288288
begin
289289
try `Lifted (Base.widen x y)
290-
with TopValue -> `Top
290+
with TopValue | Uncomparable -> `Top
291291
end
292292
| _ -> y
293293

@@ -296,7 +296,7 @@ struct
296296
| (`Lifted x, `Lifted y) ->
297297
begin
298298
try `Lifted (Base.narrow x y)
299-
with BotValue -> `Bot
299+
with BotValue | Uncomparable -> `Bot
300300
end
301301
| (_, `Bot) -> `Bot
302302
| (`Top, y) -> y
@@ -305,71 +305,7 @@ end
305305

306306
module Lift = LiftConf (Printable.DefaultConf)
307307

308-
module LiftPO (Conf: Printable.LiftConf) (Base: PO) =
309-
struct
310-
include Printable.LiftConf (Conf) (Base)
311-
312-
let bot () = `Bot
313-
let is_bot x = x = `Bot
314-
let top () = `Top
315-
let is_top x = x = `Top
316-
317-
let leq x y =
318-
match (x,y) with
319-
| (_, `Top) -> true
320-
| (`Top, _) -> false
321-
| (`Bot, _) -> true
322-
| (_, `Bot) -> false
323-
| (`Lifted x, `Lifted y) -> Base.leq x y
324-
325-
let pretty_diff () ((x:t),(y:t)): Pretty.doc =
326-
match (x,y) with
327-
| (`Lifted x, `Lifted y) -> Base.pretty_diff () (x,y)
328-
| _ -> if leq x y then Pretty.text "No Changes" else
329-
Pretty.dprintf "%a instead of %a" pretty x pretty y
330-
331-
let join x y =
332-
match (x,y) with
333-
| (`Top, _) -> `Top
334-
| (_, `Top) -> `Top
335-
| (`Bot, x) -> x
336-
| (x, `Bot) -> x
337-
| (`Lifted x, `Lifted y) ->
338-
try `Lifted (Base.join x y)
339-
with Uncomparable | TopValue -> `Top
340-
341-
let meet x y =
342-
match (x,y) with
343-
| (`Bot, _) -> `Bot
344-
| (_, `Bot) -> `Bot
345-
| (`Top, x) -> x
346-
| (x, `Top) -> x
347-
| (`Lifted x, `Lifted y) ->
348-
try `Lifted (Base.meet x y)
349-
with Uncomparable | BotValue -> `Bot
350-
351-
let widen x y =
352-
match (x,y) with
353-
| (`Lifted x, `Lifted y) ->
354-
begin
355-
try `Lifted (Base.widen x y)
356-
with Uncomparable | TopValue -> `Top
357-
end
358-
| _ -> y
359-
360-
let narrow x y =
361-
match (x,y) with
362-
| (`Lifted x, `Lifted y) ->
363-
begin
364-
try `Lifted (Base.narrow x y)
365-
with Uncomparable | BotValue -> `Bot
366-
end
367-
| (_, `Bot) -> `Bot
368-
| (`Top, y) -> y
369-
| _ -> x
370-
end
371-
372-
module Lift2Conf (Conf: Printable.Lift2Conf) (Base1: S) (Base2: S) =
308+
module Lift2Conf (Conf: Printable.Lift2Conf) (Base1: PO) (Base2: PO) =
373309
struct
374310
include Printable.Lift2Conf (Conf) (Base1) (Base2)
375311

0 commit comments

Comments
 (0)