From e107058bf6dccbe8a2e85fb8c9e45f9d6f1cbadc Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Mon, 27 Jul 2015 11:14:57 -0600 Subject: [PATCH] [Infer] Adding warning to eliminate needless rec keywords, fixing all warnings. Summary: This should make code easier to read/review in the future. --- infer/src/Makefile | 2 +- infer/src/backend/abs.ml | 4 ++-- infer/src/backend/autounit.ml | 4 ++-- infer/src/backend/dotty.ml | 4 ++-- infer/src/backend/errdesc.ml | 2 +- infer/src/backend/prop.ml | 4 ++-- infer/src/backend/rearrange.ml | 2 +- infer/src/backend/sil.ml | 12 ++++++------ infer/src/backend/tabulation.ml | 2 +- infer/src/backend/type_prop.ml | 2 +- infer/src/backend/utils.ml | 2 +- infer/src/clang/cField_decl.ml | 2 +- infer/src/clang/cMethod_trans.ml | 2 +- infer/src/java/jTrans.ml | 2 +- infer/src/java/jTransStaticField.ml | 8 ++++---- infer/src/java/jTransType.ml | 2 +- 16 files changed, 28 insertions(+), 28 deletions(-) diff --git a/infer/src/Makefile b/infer/src/Makefile index 72c1c5750..9449a8b48 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -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 #### diff --git a/infer/src/backend/abs.ml b/infer/src/backend/abs.ml index 0d7e50d54..e9d56c686 100644 --- a/infer/src/backend/abs.ml +++ b/infer/src/backend/abs.ml @@ -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 diff --git a/infer/src/backend/autounit.ml b/infer/src/backend/autounit.ml index 16965257f..411d957b2 100644 --- a/infer/src/backend/autounit.ml +++ b/infer/src/backend/autounit.ml @@ -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) diff --git a/infer/src/backend/dotty.ml b/infer/src/backend/dotty.ml index 4fd601b66..522bdff8d 100644 --- a/infer/src/backend/dotty.ml +++ b/infer/src/backend/dotty.ml @@ -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', "")] diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index c52c9dd74..95e71c9e9 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -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; diff --git a/infer/src/backend/prop.ml b/infer/src/backend/prop.ml index ee293adae..d03d169b0 100644 --- a/infer/src/backend/prop.ml +++ b/infer/src/backend/prop.ml @@ -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' diff --git a/infer/src/backend/rearrange.ml b/infer/src/backend/rearrange.ml index 6be3503e1..84fbe0df5 100644 --- a/infer/src/backend/rearrange.ml +++ b/infer/src/backend/rearrange.ml @@ -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) diff --git a/infer/src/backend/sil.ml b/infer/src/backend/sil.ml index a7ca5f921..505ad1e55 100644 --- a/infer/src/backend/sil.ml +++ b/infer/src/backend/sil.ml @@ -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 diff --git a/infer/src/backend/tabulation.ml b/infer/src/backend/tabulation.ml index f3cd0689f..1be555d4b 100644 --- a/infer/src/backend/tabulation.ml +++ b/infer/src/backend/tabulation.ml @@ -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 diff --git a/infer/src/backend/type_prop.ml b/infer/src/backend/type_prop.ml index 3c43f030d..bbdbc3fab 100644 --- a/infer/src/backend/type_prop.ml +++ b/infer/src/backend/type_prop.ml @@ -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; diff --git a/infer/src/backend/utils.ml b/infer/src/backend/utils.ml index 4ced56cf4..3f46593ab 100644 --- a/infer/src/backend/utils.ml +++ b/infer/src/backend/utils.ml @@ -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 -> diff --git a/infer/src/clang/cField_decl.ml b/infer/src/clang/cField_decl.ml index 3bee84a29..9122959c8 100644 --- a/infer/src/clang/cField_decl.ml +++ b/infer/src/clang/cField_decl.ml @@ -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] diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index d84a518e0..f338136c2 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -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)) -> diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index dafbbe1a9..250ea4b93 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -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 = diff --git a/infer/src/java/jTransStaticField.ml b/infer/src/java/jTransStaticField.ml index 6078cdd68..4e1bd8db9 100644 --- a/infer/src/java/jTransStaticField.ml +++ b/infer/src/java/jTransStaticField.ml @@ -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 *) diff --git a/infer/src/java/jTransType.ml b/infer/src/java/jTransType.ml index 00d590a11..21b555f3e 100644 --- a/infer/src/java/jTransType.ml +++ b/infer/src/java/jTransType.ml @@ -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 ->