[Infer] Adding warning to eliminate needless rec keywords, fixing all warnings.

Summary: This should make code easier to read/review in the future.
master
Sam Blackshear 9 years ago
parent f0c30fc166
commit e107058bf6

@ -43,7 +43,7 @@ ifneq ($(wildcard $(BUILDDIR)/sanitize.sh),)
endif
GLOBAL_LFLAGS = -annot
GLOBAL_CFLAGS = "-bin-annot -warn-error @5@8@10..12@20@26"
GLOBAL_CFLAGS = "-bin-annot -warn-error @5@8@10..12@20@26@39"
GLOBAL_OPTIONS = -lflags $(GLOBAL_LFLAGS) -cflags $(GLOBAL_CFLAGS) $(addprefix -lib ,$(GLOBAL_LIBS))
#### Backend declarations ####

@ -648,12 +648,12 @@ let sigma_special_cases ids sigma : (Ident.t list * Sil.hpred list) list =
list_fold_left f [] special_cases_eqs in
list_rev special_cases_rev
let rec hpara_special_cases hpara : Sil.hpara list =
let hpara_special_cases hpara : Sil.hpara list =
let update_para (evars', body') = { hpara with Sil.evars = evars'; Sil.body = body'} in
let special_cases = sigma_special_cases hpara.Sil.evars hpara.Sil.body in
list_map update_para special_cases
let rec hpara_special_cases_dll hpara : Sil.hpara_dll list =
let hpara_special_cases_dll hpara : Sil.hpara_dll list =
let update_para (evars', body') = { hpara with Sil.evars_dll = evars'; Sil.body_dll = body'} in
let special_cases = sigma_special_cases hpara.Sil.evars_dll hpara.Sil.body_dll in
list_map update_para special_cases

@ -207,7 +207,7 @@ end = struct
let (---) n1_op n2_op = match n1_op, n2_op with
| Some n1, Some n2 -> Some (Sil.Int.sub n1 n2)
| _ -> None in
let rec do_le e1 e2 = match e1, e2 with
let do_le e1 e2 = match e1, e2 with
| Sil.Var id, Sil.Const (Sil.Cint n) ->
let rng = IdMap.find id ev in
add_top rng id n
@ -222,7 +222,7 @@ end = struct
update_top rng1 id1 (Some n --- rng2.bottom);
update_top rng2 id2 (Some n --- rng1.bottom)
| _ -> if debug then assert false in
let rec do_lt e1 e2 = match e1, e2 with
let do_lt e1 e2 = match e1, e2 with
| Sil.Const (Sil.Cint n), Sil.Var id ->
let rng = IdMap.find id ev in
add_bottom rng id (n ++ Sil.Int.one)

@ -218,7 +218,7 @@ let rec select_nodes_exp_lambda dotnodes e lambda =
(* look-up the coordinate id in the list of dotnodes those nodes which correspond to expression e*)
(* this is written in this strange way for legacy reason. It should be changed a bit*)
let rec look_up dotnodes e lambda =
let look_up dotnodes e lambda =
let r = select_nodes_exp_lambda dotnodes e lambda in
let r'= list_map get_coordinate_id r in
r' @ look_up_for_back_pointer e dotnodes lambda
@ -477,7 +477,7 @@ let rec compute_target_array_elements dotnodes list_elements p f lambda =
let targets_a = find_target_one_element a in
targets_a @ compute_target_array_elements dotnodes list_ele' p f lambda
let rec compute_target_from_eexp dotnodes e p f lambda =
let compute_target_from_eexp dotnodes e p f lambda =
if is_nil e p then
let n'= make_nil_node lambda in
[(LinkExpToExp, n', "")]

@ -217,7 +217,7 @@ let pvar_is_frontend_tmp pvar =
let rec _find_normal_variable_letderef (seen : Sil.ExpSet.t) node id : Sil.dexp option =
let res = ref None in
let node_instrs = Cfg.Node.get_instrs node in
let rec find_declaration = function
let find_declaration = function
| Sil.Letderef (id0, e, _, _) when Ident.equal id id0 ->
if !verbose then (L.d_str "find_normal_variable_letderef defining "; Sil.d_exp e; L.d_ln ());
res := _exp_lv_dexp seen node e;

@ -377,7 +377,7 @@ let prop_fav_nonpure_add fav prop =
let prop_fav_nonpure =
Sil.fav_imperative_to_functional prop_fav_nonpure_add
let rec hpred_fav_in_pvars_add fav = function
let hpred_fav_in_pvars_add fav = function
| Sil.Hpointsto (Sil.Lvar _, sexp, _) -> Sil.strexp_fav_add fav sexp
| Sil.Hpointsto _ | Sil.Hlseg _ | Sil.Hdllseg _ -> ()
@ -1438,7 +1438,7 @@ let replace_sigma_footprint sigma (prop : 'a t) : exposed t =
let replace_pi_footprint pi (prop : 'a t) : exposed t =
{ prop with foot_pi = pi }
let rec sigma_replace_exp epairs sigma =
let sigma_replace_exp epairs sigma =
let sigma' = list_map (Sil.hpred_replace_exp epairs) sigma in
sigma_normalize Sil.sub_empty sigma'

@ -385,7 +385,7 @@ let strexp_extend_values
| _ -> Sil.Subtype.exact in
list_map (fun (atoms', se', typ') -> (laundry_atoms @ atoms', se', Sil.Sizeof (typ', st))) atoms_se_typ_list_filtered
let rec collect_root_offset exp =
let collect_root_offset exp =
let root = Sil.root_of_lexp exp in
let offsets = Sil.exp_get_offsets exp in
(root, offsets)

@ -2178,7 +2178,7 @@ let instr_get_loc = function
loc
(** get the expressions occurring in the instruction *)
let rec instr_get_exps = function
let instr_get_exps = function
| Letderef (id, e, _, _) ->
[Var id; e]
| Set (e1, _, e2, _) ->
@ -2206,7 +2206,7 @@ let pp_call_flags f cf =
if cf.cf_noreturn then F.fprintf f " noreturn"
(** Pretty print an instruction. *)
let rec pp_instr pe0 f instr =
let pp_instr pe0 f instr =
let pe, changed = color_pre_wrapper pe0 f instr in
(match instr with
| Letderef (id, e, t, loc) -> F.fprintf f "%a=*%a:%a %a" (Ident.pp pe) id (pp_exp pe) e (pp_typ pe) t pp_loc loc
@ -2305,7 +2305,7 @@ and exp_iter_types f e =
typ_iter_types f t
(** Iterate over all the types (and subtypes) in the instruction *)
let rec instr_iter_types f instr = match instr with
let instr_iter_types f instr = match instr with
| Letderef (id, e, t, loc) ->
exp_iter_types f e;
typ_iter_types f t
@ -3132,7 +3132,7 @@ let exp_fav =
let exp_fav_list e =
fav_to_list (exp_fav e)
let rec ident_in_exp id e =
let ident_in_exp id e =
let fav = fav_new () in
exp_fav_add fav e;
fav_mem fav id
@ -3157,7 +3157,7 @@ let rec strexp_fav_add fav = function
exp_fav_add fav size;
list_iter (fun (e, se) -> exp_fav_add fav e; strexp_fav_add fav se) idx_se_list
let rec hpred_fav_add fav = function
let hpred_fav_add fav = function
| Hpointsto (base, sexp, te) -> exp_fav_add fav base; strexp_fav_add fav sexp; exp_fav_add fav te
| Hlseg (_, para, e1, e2, elist) ->
hpara_fav_add fav para;
@ -3617,7 +3617,7 @@ let rec strexp_replace_exp epairs = function
(idx', strexp_replace_exp epairs se) in
Earray (size', list_map f isel, inst)
let rec hpred_replace_exp epairs = function
let hpred_replace_exp epairs = function
| Hpointsto (root, se, te) ->
let root_repl = exp_replace_exp epairs root in
let strexp_repl = strexp_replace_exp epairs se in

@ -405,7 +405,7 @@ let texp_star texp1 texp2 =
| n when n < 0 -> false
| 0 -> ftal_sub ftal1' ftal2'
| _ -> ftal_sub ftal1 ftal2' end in
let rec typ_star t1 t2 = match t1, t2 with
let typ_star t1 t2 = match t1, t2 with
| Sil.Tstruct (ftal1, sftal1, csu1, _, _, _, _), Sil.Tstruct (ftal2, sftal2, csu2, _, _, _, _) when csu1 = csu2 ->
if ftal_sub ftal1 ftal2 then t2 else t1
| _ -> t1 in

@ -726,7 +726,7 @@ let () =
(* Initialises the map of types of the methods that are never called with *)
(* the static types. *)
let initialize_map exe_env methods =
let rec init_method exe_env pname map =
let init_method exe_env pname map =
let cfg = Exe_env.get_cfg exe_env pname in
let formals = get_formals cfg pname in
initial_methods := Procname.Set.add pname !initial_methods;

@ -363,7 +363,7 @@ let pp_semicolon_seq pe = _pp_semicolon_seq false pe
let pp_semicolon_seq_oneline pe = _pp_semicolon_seq true pe
(** Print an or-separated sequence. *)
let rec pp_or_seq pe pp f = function
let pp_or_seq pe pp f = function
| [] -> ()
| [x] -> F.fprintf f "%a" pp x
| x:: l ->

@ -49,7 +49,7 @@ let get_field_www name_field fl =
"WARNING: In MemberExpr there must be only one type defininf for the struct. Returning (NO_FIELD_NAME, Tvoid)\n"
(Ident.create_fieldname (Mangled.from_string "NO_FIELD_NAME") 0, Sil.Tvoid)
let rec build_sil_field tenv class_name field_name qual_type prop_atts =
let build_sil_field tenv class_name field_name qual_type prop_atts =
let annotation_from_type t =
match t with
| Sil.Tptr (_, Sil.Pk_objc_weak) -> [Config.weak]

@ -33,7 +33,7 @@ let mk_procname_from_function name type_name =
let mk_procname_from_method class_name method_name =
Procname.mangled_c_method class_name method_name None
let rec resolve_method_class tenv class_name method_name =
let resolve_method_class tenv class_name method_name =
let type_name = Sil.TN_csu (Sil.Class, class_name) in
match Sil.tenv_lookup tenv type_name with
| Some (Sil.Tstruct (_, _, Sil.Class, cls, super_classes, methods, iann)) ->

@ -759,7 +759,7 @@ let resolve_method context cn ms =
(* TODO: unclear if this corresponds to what JControlFlow.resolve_method'*)
(* is trying to do. Normally, this implementation below goes deeper into *)
(* the type hierarchy and it is not clear why we should not do that *)
let rec extends context node1 node2 =
let extends context node1 node2 =
let is_matching cn =
JBasics.cn_equal cn (Javalib.get_name node2) in
let rec check cn_list =

@ -34,7 +34,7 @@ let is_basic_type fs =
(** Returns whether the node contains static final fields
that are not of a primitive type or String. *)
let rec has_static_final_fields node =
let has_static_final_fields node =
let detect fs f test =
test || (Javalib.is_static_field f && Javalib.is_final_field f) in
JBasics.FieldMap.fold detect (Javalib.get_fields node) false
@ -110,7 +110,7 @@ let has_unclear_control_flow code =
for returning the field selected by the parameter. *)
(* The constant s means the parameter field of the function.
Note that we remove the initialisation of non - final static fields. *)
let rec static_field_init_complex cn code fields length =
let static_field_init_complex cn code fields length =
let code = Array.append [| (JBir.Goto length ) |] code in
let s = JConfig.field_cst in
let field_pc_list = ref [] in
@ -142,7 +142,7 @@ let rec static_field_init_complex cn code fields length =
(** In the initialiser of static fields, we add instructions
for returning the field selected by the parameter without changing
the control flow of the original code. *)
let rec static_field_init_simple cn code fields length =
let static_field_init_simple cn code fields length =
let s = JConfig.field_cst in
let rec aux s pc fields =
match fields with
@ -168,7 +168,7 @@ let rec static_field_init_simple cn code fields length =
In these cases it is not possible to separate the code for the initialisation
of each field, so we do not change the original code, but append intructions
for returning the selected field. *)
let rec static_field_init node cn code =
let static_field_init node cn code =
try
let field_list = JBasics.FieldMap.elements (Javalib.get_fields node) in
(* TODO: this translation to a list can be removed and map iterators can be used afterward *)

@ -161,7 +161,7 @@ let cn_to_java_type cn =
(JBasics.cn_simple_name cn))
let rec vt_to_java_type vt =
let vt_to_java_type vt =
match vt with
| JBasics.TBasic bt -> None, string_of_basic_type bt
| JBasics.TObject ot ->

Loading…
Cancel
Save