@@ -27,9 +27,9 @@ let map_gvar f = function
2727
2828let is_temporary id = Inthash. mem allTempVars id
2929
30- let generate_func_loc_table cilfile =
31- Util. list_filter_map
32- (map_gfun (fun dec loc -> Some ( dec.svar.vname, loc.line) ))
30+ let get_func_loc cilfile fname =
31+ List. find_map
32+ (map_gfun (fun dec loc -> if dec.svar.vname = fname then Some loc else None ))
3333 cilfile.globals
3434
3535let generate_globalvar_list cilfile =
@@ -38,26 +38,13 @@ let generate_globalvar_list cilfile =
3838 cilfile.globals
3939
4040let get_all_alphaconverted_in_fun varname funname cilfile =
41- let fun_loc_table = generate_func_loc_table cilfile in
42- let loc_start =
43- snd
44- @@ List. find (function x , _ -> String. compare x funname = 0 ) fun_loc_table
45- in
46- let rec iter_fun_loc list =
47- match list with
48- | (fname , _ ) :: xs ->
49- if fname = funname then
50- match xs with (_ , line ) :: _ -> line | [] -> max_int
51- else iter_fun_loc xs
52- | [] -> 0
53- in
54- let loc_end = iter_fun_loc fun_loc_table in
41+ let fun_loc = Option. get (get_func_loc cilfile funname) in
42+ let loc_within_fun loc = loc.file = fun_loc.file
43+ && loc.line > = fun_loc.line && (loc.line < fun_loc.endLine || fun_loc.endLine < 0 ) in
5544 let tmp =
5645 Util. list_filter_map
5746 (function
58- | EnvVar varinfo, loc when loc.line > = loc_start && loc.line < loc_end
59- ->
60- Some varinfo.vname
47+ | EnvVar varinfo , loc when loc_within_fun loc-> Some varinfo.vname
6148 | _ -> None )
6249 (Hashtbl. find_all environment varname)
6350 in
0 commit comments