Skip to content

Commit

Permalink
Merge pull request #106 from goblint/ocaml-5
Browse files Browse the repository at this point in the history
Remove batteries dependency to support OCaml 5
  • Loading branch information
sim642 authored Jul 22, 2022
2 parents 92625c8 + fd6fe96 commit e4f4445
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
- ubuntu-latest
# - windows-latest
ocaml-version:
# - 4.04.2
- 4.05.0
- 4.06.1
- 4.07.1
Expand All @@ -26,6 +25,7 @@ jobs:
- 4.12.0
- 4.13.1
- 4.14.x
- ocaml-base-compiler.5.0.0~alpha1


runs-on: ${{ matrix.os }}
Expand Down
1 change: 0 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Changes:
stdlib-shims
(ppx_deriving_yojson (>= 3.2))
yojson
(batteries (>= 3.2.0))
conf-perl
cppo
)
Expand Down
1 change: 0 additions & 1 deletion goblint-cil.opam
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ depends: [
"stdlib-shims"
"ppx_deriving_yojson" {>= "3.2"}
"yojson"
"batteries" {>= "3.2.0"}
"conf-perl"
"cppo"
]
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(public_name goblint-cil)
(name cil)
(wrapped false) ; this should be changed, but then module paths in goblint need to be prefixed
(libraries zarith findlib dynlink unix str stdlib-shims batteries.unthreaded) ; batteries shouldn't be needed, but tests fail on MacOS otherwise: https://github.com/goblint/cil/pull/89#issuecomment-1092610041
(libraries zarith findlib dynlink unix str stdlib-shims)
(modules (:standard \ main machdepConfigure))
)

Expand Down
2 changes: 1 addition & 1 deletion src/ext/syntacticsearch/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
(public_name goblint-cil.syntacticsearch)
(name syntacticsearch)
(wrapped false) ; this should be changed, but then module paths in goblint need to be prefixed
(libraries goblint-cil yojson ppx_deriving_yojson.runtime batteries.unthreaded)
(libraries goblint-cil yojson ppx_deriving_yojson.runtime)
(preprocess (pps ppx_deriving_yojson))
)
10 changes: 5 additions & 5 deletions src/ext/syntacticsearch/funcDatatype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ open Cil

(* Finds definition of a user-defined type *)
let find_def name file =
BatList.filter_map
Util.list_filter_map
(function
| GType (info, loc) ->
if String.compare name info.tname = 0 then Some ("", loc, name, -1)
Expand All @@ -18,7 +18,7 @@ let find_def name file =

(* Finds all definition of user-defined types *)
let find_def_all file =
BatList.filter_map
Util.list_filter_map
(function
| GType (info, loc) -> Some ("", loc, info.tname, -1)
| GCompTag (info, loc) -> Some ("", loc, info.cname, -1)
Expand All @@ -27,7 +27,7 @@ let find_def_all file =
file.globals

let find_in_globals list name =
BatList.filter_map
Util.list_filter_map
(function
| GVar (info, _, _) ->
if
Expand All @@ -40,7 +40,7 @@ let find_in_globals list name =
list

let find_in_varinfos list name =
BatList.filter_map
Util.list_filter_map
(fun info ->
if
String.compare name
Expand All @@ -52,7 +52,7 @@ let find_in_varinfos list name =

let find_fundec globals name =
let gfun =
BatList.find_opt
List.find_opt
(function
| GFun (fundec, _) -> String.compare fundec.svar.vname name = 0
| _ -> false)
Expand Down
32 changes: 16 additions & 16 deletions src/ext/syntacticsearch/funcFunction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let map_gfun f = function GFun (dec, loc) -> f dec loc | _ -> None

let find_all_with_origname n =
let ns = Hashtbl.find_all environment n in
BatList.filter_map (function | (EnvVar v,_) -> Some v.vname | _ -> None) ns
Util.list_filter_map (function | (EnvVar v,_) -> Some v.vname | _ -> None) ns

class fun_find_returns funname funid result : nopCilVisitor =
object
Expand Down Expand Up @@ -58,7 +58,7 @@ let find_returns funname funid file =
(* Finds all returns in all functions *)
let find_returns_all file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ -> Some (find_returns "" fundec.svar.vid file)))
file.globals

Expand Down Expand Up @@ -121,18 +121,18 @@ let find_def funname funid file =
Some (fundec.svar.vname, loc, create_sig fundec file, fundec.svar.vid)
else None
in
BatList.filter_map (map_gfun fn) file.globals
Util.list_filter_map (map_gfun fn) file.globals

(* Finds all definitions of all functions *)
let find_def_all file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ -> Some (find_def "" fundec.svar.vid file)))
file.globals

let find_fundec funname funid list =
let gfun =
BatList.find_opt
List.find_opt
(fun x ->
match x with
| GFun (dec, _) -> is_equal_funname_funid dec.svar funname funid
Expand Down Expand Up @@ -170,7 +170,7 @@ let find_uses funname funid file =
(* Find all calls of all functions in all functions *)
let find_uses_all file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ -> Some (find_uses "" fundec.svar.vid file)))
file.globals

Expand Down Expand Up @@ -210,7 +210,7 @@ let find_uses_in_fun funname funid funstrucname file =
(* Finds all calls of all functions in a function *)
let find_uses_in_fun_all funstrucname file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ ->
Some (find_uses_in_fun "" fundec.svar.vid funstrucname file)))
file.globals
Expand Down Expand Up @@ -272,7 +272,7 @@ let find_usesvar_in_fun funname funid funstrucname varname file =
(* Finds calls of all function with a var in argument in a function *)
let find_usesvar_in_fun_all funstrucname varname file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ ->
Some
(find_usesvar_in_fun "" fundec.svar.vid funstrucname varname file)))
Expand All @@ -281,7 +281,7 @@ let find_usesvar_in_fun_all funstrucname varname file =
(* Finds all calls of a function with a var in argument in all functions *)
let find_usesvar funname funid varname file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ ->
Some
(find_usesvar_in_fun funname funid fundec.svar.vname varname file)))
Expand All @@ -290,7 +290,7 @@ let find_usesvar funname funid varname file =
(* Finds all calls of all functions with a var in argument in all functions *)
let find_usesvar_all varname file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ ->
Some (find_usesvar "" fundec.svar.vid varname file)))
file.globals
Expand Down Expand Up @@ -331,7 +331,7 @@ let create_fun_res name id file loc =
(* Finds all calls of a function in a condition in all functions *)
let find_uses_cond funname funid file =
let id_list = find_lval_of_calls funname funid file in
BatList.filter_map
Util.list_filter_map
(fun (tmp, func) ->
match FuncVar.find_uses_in_cond "" tmp file true with
| (_, loc, _, _) :: _ -> Some (create_fun_res "" func file loc)
Expand All @@ -341,7 +341,7 @@ let find_uses_cond funname funid file =
(* Finds all calls of all functions in a condition in all functions *)
let find_uses_cond_all file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ -> Some (find_uses_cond "" fundec.svar.vid file)))
file.globals

Expand All @@ -354,7 +354,7 @@ let find_uses_noncond funname funid file =
(* Finds calls of all functions in non-condition in all functions *)
let find_uses_noncond_all file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ ->
Some (find_uses_noncond "" fundec.svar.vid file)))
file.globals
Expand Down Expand Up @@ -397,7 +397,7 @@ let find_lval_of_calls_usesvar funname funid varname file =
(* Finds calls of a function with a variable as argument in conditions *)
let find_usesvar_cond funname funid varname file =
let id_list = find_lval_of_calls_usesvar funname funid varname file in
BatList.filter_map
Util.list_filter_map
(fun (tmp, func) ->
match FuncVar.find_uses_in_cond "" tmp file true with
| (_, loc, _, _) :: _ -> Some (create_fun_res "" func file loc)
Expand All @@ -407,7 +407,7 @@ let find_usesvar_cond funname funid varname file =
(* Finds calls of all functions with a variable as argument in conditions *)
let find_usesvar_cond_all varname file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ ->
Some (find_usesvar_cond "" fundec.svar.vid varname file)))
file.globals
Expand All @@ -421,7 +421,7 @@ let find_usesvar_noncond funname funid varname file =
(* Finds calls of all functions with a variable as argument in non-conditions *)
let find_usesvar_noncond_all varname file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun fundec _ ->
Some (find_usesvar_noncond "" fundec.svar.vid varname file)))
file.globals
38 changes: 19 additions & 19 deletions src/ext/syntacticsearch/funcVar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ let map_gvar f = function
let is_temporary id = Inthash.mem allTempVars id

let generate_func_loc_table cilfile =
BatList.filter_map
Util.list_filter_map
(map_gfun (fun dec loc -> Some (dec.svar.vname, loc.line)))
cilfile.globals

let generate_globalvar_list cilfile =
BatList.filter_map
Util.list_filter_map
(map_gvar (fun varinfo _ _ -> Some varinfo.vname))
cilfile.globals

Expand All @@ -53,7 +53,7 @@ let get_all_alphaconverted_in_fun varname funname cilfile =
in
let loc_end = iter_fun_loc fun_loc_table in
let tmp =
BatList.filter_map
Util.list_filter_map
(function
| EnvVar varinfo, loc when loc.line >= loc_start && loc.line < loc_end
->
Expand Down Expand Up @@ -223,7 +223,7 @@ let find_uses_in_fun_var dec name varid includeCallTmp cilfile =
(* Finds the function in which a variable shall be found *)
let find_uses_in_fun_find_fun list name varname varid includeCallTmp cilfile =
let r =
BatList.find_opt
List.find_opt
(function
| GFun (dec, _) -> String.compare dec.svar.vname name = 0 | _ -> false)
list
Expand All @@ -239,7 +239,7 @@ let find_uses_in_fun varname varid funname file includeCallTmp =
file

let find_all_glob_vars list =
BatList.filter_map (map_gvar (fun info _ _ -> Some info.vid)) list
Util.list_filter_map (map_gvar (fun info _ _ -> Some info.vid)) list

(* Finds all uses of all global variables in a function *)
let find_uses_in_fun_all_glob funname file includeCallTmp =
Expand All @@ -251,7 +251,7 @@ let find_uses_in_fun_all_glob funname file includeCallTmp =

let find_fundec globals funname =
let r =
BatList.find_opt
List.find_opt
(function
| GFun (dec, _) -> String.compare dec.svar.vname funname = 0
| _ -> false)
Expand All @@ -274,7 +274,7 @@ let find_uses_in_fun_all funname file includeCallTmp =

let find_var_in_globals varname varid list =
let r =
BatList.find_opt
List.find_opt
(function
| GVar (info, _, _) -> is_equal_varname_varid info varname varid
| _ -> false)
Expand All @@ -294,7 +294,7 @@ let find_var_in_globals varname varid list =
let find_uses varname varid file includeCallTmp =
let uses_in_all_fun =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ ->
Some
(find_uses_in_fun varname varid dec.svar.vname file
Expand All @@ -307,7 +307,7 @@ let find_uses varname varid file includeCallTmp =
let find_uses_all_glob file includeCallTmp =
let res =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ ->
Some
(find_uses_in_fun_all_glob dec.svar.vname file includeCallTmp)))
Expand All @@ -323,7 +323,7 @@ let find_uses_all_glob file includeCallTmp =
let find_uses_all file includeCallTmp =
let res =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ ->
Some (find_uses_in_fun_all dec.svar.vname file includeCallTmp)))
file.globals
Expand Down Expand Up @@ -422,7 +422,7 @@ let find_uses_in_cond_in_fun_all funname file includeCallTmp =
(* Finds all uses of variables in conditions in all functions *)
let find_uses_in_cond_all file includeCallTmp =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ ->
Some
(find_uses_in_cond_in_fun_all dec.svar.vname file includeCallTmp)))
Expand Down Expand Up @@ -456,7 +456,7 @@ let find_uses_in_noncond_all file includeCallTmp =
let find_decl_in_fun varname varid funname file =
let get_formals_locals dec = dec.sformals @ dec.slocals in
let iter_list_name list name =
BatList.filter_map
Util.list_filter_map
(fun x ->
if String.compare x.vname name = 0 && not (is_temporary x.vid) then
Some
Expand All @@ -474,7 +474,7 @@ let find_decl_in_fun varname varid funname file =
| None -> []
| Some fundec ->
if varid != -1 then
BatList.filter_map
Util.list_filter_map
(fun x ->
if x.vid = varid then
Some
Expand Down Expand Up @@ -504,7 +504,7 @@ let find_decl_in_fun_all funname file =

(* Finds all global variable declarations *)
let find_decl_all_glob file =
BatList.filter_map
Util.list_filter_map
(map_gvar (fun info _ loc ->
Some
( info.vname,
Expand Down Expand Up @@ -536,7 +536,7 @@ let find_decl varname varid file =
let find_decl_all file =
let list =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ ->
Some (find_decl_in_fun_all dec.svar.vname file)))
file.globals
Expand Down Expand Up @@ -588,7 +588,7 @@ let find_defs_in_fun varname varid funname file =
(* Finds definitions of all global variables in a function *)
let find_defs_in_fun_all_glob funname file =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gvar (fun info _ _ ->
Some (find_defs_in_fun "" info.vid funname file)))
file.globals
Expand All @@ -610,7 +610,7 @@ let find_defs_in_fun_all funname file =
let find_defs varname varid file =
let r =
List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ ->
Some (find_defs_in_fun varname varid dec.svar.vname file)))
file.globals
Expand All @@ -624,7 +624,7 @@ let find_defs_all_glob file =
(fun x -> find_var_in_globals "" x file.globals)
(find_all_glob_vars file.globals))
@ List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ ->
Some (find_defs_in_fun_all_glob dec.svar.vname file)))
file.globals
Expand All @@ -636,6 +636,6 @@ let find_defs_all file =
(fun x -> find_var_in_globals "" x file.globals)
(find_all_glob_vars file.globals))
@ List.flatten
@@ BatList.filter_map
@@ Util.list_filter_map
(map_gfun (fun dec _ -> Some (find_defs_in_fun_all dec.svar.vname file)))
file.globals
Loading

0 comments on commit e4f4445

Please sign in to comment.