Skip to content

Commit 0b677c6

Browse files
Change Apron hashcons check to fail and use usesApron flag
- Add usesApron flag to MCPRegistry.spec_modules - Add optional ~usesApron parameter to register_analysis (default false) - Add any_activated_uses_apron() function to check registry - Mark Apron analyses with ~usesApron:true flag - Change warning to fail when hashcons disabled with Apron Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
1 parent 004be4c commit 0b677c6

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/analyses/apron/affineEqualityAnalysis.apron.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let get_spec (): (module MCPSpec) =
4343

4444
let after_config () =
4545
let module Spec = (val get_spec ()) in
46-
MCP.register_analysis (module Spec : MCPSpec);
46+
MCP.register_analysis ~usesApron:true (module Spec : MCPSpec);
4747
GobConfig.set_string "ana.path_sens[+]" (Spec.name ())
4848

4949
let _ =

src/analyses/apron/apronAnalysis.apron.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let get_spec (): (module MCPSpec) =
2323

2424
let after_config () =
2525
let module Spec = (val get_spec ()) in
26-
MCP.register_analysis (module Spec : MCPSpec);
26+
MCP.register_analysis ~usesApron:true (module Spec : MCPSpec);
2727
GobConfig.set_string "ana.path_sens[+]" (Spec.name ())
2828

2929
let _ =

src/analyses/apron/linearTwoVarEqualityAnalysis.apron.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let get_spec (): (module MCPSpec) =
2424

2525
let after_config () =
2626
let module Spec = (val get_spec ()) in
27-
MCP.register_analysis (module Spec : MCPSpec);
27+
MCP.register_analysis ~usesApron:true (module Spec : MCPSpec);
2828
GobConfig.set_string "ana.path_sens[+]" (Spec.name ())
2929

3030
let _ =

src/analyses/mCPRegistry.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ type spec_modules = { name : string
1414
; cont : (module Printable.S)
1515
; var : (module SpecSysVar)
1616
; acc : (module MCPA)
17-
; path : (module DisjointDomain.Representative) }
17+
; path : (module DisjointDomain.Representative)
18+
; usesApron : bool }
1819

1920
let activated : (int * spec_modules) list ref = ref []
2021
let activated_context_sens: (int * spec_modules) list ref = ref []
@@ -24,7 +25,7 @@ let registered_name: (string, int) Hashtbl.t = Hashtbl.create 100
2425

2526
let register_analysis =
2627
let count = ref 0 in
27-
fun ?(dep=[]) (module S:MCPSpec) ->
28+
fun ?(dep=[]) ?(usesApron=false) (module S:MCPSpec) ->
2829
let n = S.name () in
2930
let module P =
3031
struct
@@ -41,6 +42,7 @@ let register_analysis =
4142
; var = (module S.V : SpecSysVar)
4243
; acc = (module S.A : MCPA)
4344
; path = (module P : DisjointDomain.Representative)
45+
; usesApron
4446
}
4547
in
4648
Hashtbl.replace registered !count s;
@@ -51,6 +53,9 @@ let find_spec = Hashtbl.find registered
5153
let find_spec_name n = (find_spec n).name
5254
let find_id = Hashtbl.find registered_name
5355

56+
let any_activated_uses_apron () =
57+
List.exists (fun (n, _) -> (find_spec n).usesApron) !activated
58+
5459
module type DomainListPrintableSpec =
5560
sig
5661
val assoc_dom : int -> (module Printable.S)

src/maingoblint.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ let check_arguments () =
139139
if not (get_bool "ana.opt.hashcons") then (
140140
if get_bool "exp.arg.enabled" then
141141
warn "Disabling ana.opt.hashcons has no effect because hashconsing is implicitly enabled by exp.arg.enabled";
142-
if List.mem "apron" (get_string_list "ana.activated") then
143-
warn "Disabling ana.opt.hashcons has no effect because hashconsing is implicitly enabled by Apron (ana.activated includes 'apron')";
142+
if MCPRegistry.any_activated_uses_apron () then
143+
fail "Disabling ana.opt.hashcons is not supported when using Apron domains";
144144
);
145145
if List.mem "remove_dead_code" @@ get_string_list "trans.activated" then (
146146
(* 'assert' transform happens before 'remove_dead_code' transform *)

0 commit comments

Comments
 (0)