Skip to content

Commit

Permalink
avoid List.find_map and Option module to support OCaml >= 4.05
Browse files Browse the repository at this point in the history
  • Loading branch information
stilscher committed Jun 21, 2023
1 parent 99da0cb commit f89a373
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ext/syntacticsearch/funcVar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ let map_gvar f = function

let is_temporary id = Inthash.mem allTempVars id

(* fails when there is no function with name fname in cilfile *)
let get_func_loc cilfile fname =
List.find_map
(map_gfun (fun dec loc -> if dec.svar.vname = fname then Some loc else None))
cilfile.globals
let rec find_loc = function
| [] -> failwith ("no function with name " ^ fname ^ " found")
| GFun (fd, loc) :: l when fd.svar.vname = fname -> loc
| _ :: l -> find_loc l in
find_loc cilfile.globals

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

let get_all_alphaconverted_in_fun varname funname cilfile =
let fun_loc = Option.get (get_func_loc cilfile funname) in
let fun_loc = get_func_loc cilfile funname in
let loc_within_fun loc = loc.file = fun_loc.file
&& loc.line >= fun_loc.line && (loc.line < fun_loc.endLine || fun_loc.endLine < 0) in
let tmp =
Expand Down

0 comments on commit f89a373

Please sign in to comment.