Skip to content

Commit

Permalink
Add V module to Spec for global constraint variables (issue #469)
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Dec 1, 2021
1 parent 6e21622 commit 09ff824
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/analyses/apron/apronAnalysis.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct
module C = D

open AD
open (ApronDomain: (sig module V: (module type of ApronDomain.V) end)) (* open only V from ApronDomain (to shadow V of Spec), but don't open D (to not shadow D here) *)

open ApronPrecCompareUtil
(* Result map used for comparison of results *)
Expand Down
14 changes: 12 additions & 2 deletions src/analyses/mCP.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module QuerySet = Set.Make (Queries.Any)
type spec_modules = { spec : (module MCPSpec)
; dom : (module Lattice.S)
; glob : (module Lattice.S)
; cont : (module Printable.S) }
; cont : (module Printable.S)
; var : (module Printable.S) }

let analyses_list : (int * spec_modules) list ref = ref []
let analyses_list' : (int * spec_modules) list ref = ref []
Expand All @@ -25,6 +26,7 @@ let register_analysis =
; dom = (module S.D : Lattice.S)
; glob = (module S.G : Lattice.S)
; cont = (module S.C : Printable.S)
; var = (module S.V : Printable.S)
}
in
let n = S.name () in
Expand Down Expand Up @@ -217,14 +219,22 @@ struct
let domain_list () = List.map (fun (n,p) -> n, p.cont) !analyses_list
end

module VarListSpec : DomainListPrintableSpec =
struct
let assoc_dom n = (List.assoc n !analyses_list).var
let domain_list () = List.map (fun (n,p) -> n, p.var) !analyses_list
end

module MCP2 : Analyses.Spec
with module D = DomListLattice (LocalDomainListSpec)
and module G = DomListLattice (GlobalDomainListSpec)
and module C = DomListPrintable (ContextListSpec) =
and module C = DomListPrintable (ContextListSpec)
and module V = DomListPrintable (VarListSpec) =
struct
module D = DomListLattice (LocalDomainListSpec)
module G = DomListLattice (GlobalDomainListSpec)
module C = DomListPrintable (ContextListSpec)
module V = DomListPrintable (VarListSpec)

open List open Obj

Expand Down
4 changes: 4 additions & 0 deletions src/framework/analyses.ml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ sig
module D : Lattice.S
module G : Lattice.S
module C : Printable.S
module V: Printable.S (** Global constraint variables. *)

val name : unit -> string

Expand Down Expand Up @@ -487,10 +488,13 @@ struct
BatPrintf.fprintf f "<context>\n%a</context>\n%a" C.printXml c D.printXml d
end

module VarinfoV = CilType.Varinfo

(** Relatively safe default implementations of some boring Spec functions. *)
module DefaultSpec =
struct
module V = VarinfoV

type marshal = unit
let init _ = ()
let finalize () = ()
Expand Down
7 changes: 7 additions & 0 deletions src/framework/constraints.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct
module D = Lattice.HConsed (S.D)
module G = S.G
module C = S.C
module V = S.V

let name () = S.name () ^" hashconsed"

Expand Down Expand Up @@ -95,6 +96,7 @@ struct
module D = S.D
module G = S.G
module C = Printable.HConsed (S.C)
module V = S.V

let name () = S.name () ^" context hashconsed"

Expand Down Expand Up @@ -182,6 +184,7 @@ struct
module D = Lattice.Prod (S.D) (Lattice.Reverse (IntDomain.Lifted))
module G = S.G
module C = S.C
module V = S.V

let name () = S.name ()^" level sliced"

Expand Down Expand Up @@ -322,6 +325,7 @@ struct
end
module G = S.G
module C = S.C
module V = S.V


let name () = S.name ()^" with widened contexts"
Expand Down Expand Up @@ -391,6 +395,7 @@ struct
module D = Dom (S.D)
module G = S.G
module C = S.C
module V = S.V

let name () = S.name ()^" lifted"

Expand Down Expand Up @@ -897,6 +902,7 @@ module PathSensitive2 (Spec:Spec)
with type D.t = HoareDomain.Set(Spec.D).t
and module G = Spec.G
and module C = Spec.C
and module V = Spec.V
=
struct
module D =
Expand Down Expand Up @@ -938,6 +944,7 @@ struct

module G = Spec.G
module C = Spec.C
module V = Spec.V

let name () = "PathSensitive2("^Spec.name ()^")"

Expand Down
1 change: 1 addition & 0 deletions src/witness/witnessConstraints.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ struct

module G = Spec.G
module C = Spec.C
module V = Spec.V

let name () = "PathSensitive3("^Spec.name ()^")"

Expand Down

0 comments on commit 09ff824

Please sign in to comment.