From 28b696881cc5ce3aa360bff84a3357395659aee3 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Wed, 9 May 2018 02:56:36 -0700 Subject: [PATCH] [minor] Use List.is_empty instead of List.length equal to 0 Reviewed By: mbouaziz, jvillard Differential Revision: D7909827 fbshipit-source-id: 4ea8b90 --- infer/src/IR/Subtype.ml | 2 +- infer/src/backend/dotty.ml | 2 +- infer/src/biabduction/Tabulation.ml | 2 +- infer/src/checkers/uninit.ml | 2 +- infer/src/clang/cMethod_trans.ml | 2 +- infer/src/clang/cTrans.ml | 4 ++-- infer/src/java/jTrans.ml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/infer/src/IR/Subtype.ml b/infer/src/IR/Subtype.ml index 0afe2d7f1..8d0288e4a 100644 --- a/infer/src/IR/Subtype.ml +++ b/infer/src/IR/Subtype.ml @@ -14,7 +14,7 @@ open! IStd module F = Format let list_to_string list = - if Int.equal (List.length list) 0 then "( sub )" + if List.is_empty list then "( sub )" else "- {" ^ String.concat ~sep:", " (List.map ~f:Typ.Name.name list) ^ "}" diff --git a/infer/src/backend/dotty.ml b/infer/src/backend/dotty.ml index 6dc2f10d2..40e24a041 100644 --- a/infer/src/backend/dotty.ml +++ b/infer/src/backend/dotty.ml @@ -1103,7 +1103,7 @@ let pp_cfgnodelabel pdesc fmt (n: Procdesc.Node.t) = let byvals = attributes.ProcAttributes.by_vals in Format.fprintf fmt "Start %s\\nFormals: %a\\nLocals: %a" pname_string (pp_etlist byvals) (Procdesc.get_formals pdesc) pp_local_list (Procdesc.get_locals pdesc) ; - if List.length (Procdesc.get_captured pdesc) <> 0 then + if not (List.is_empty (Procdesc.get_captured pdesc)) then Format.fprintf fmt "\\nCaptured: %a" pp_var_list (Procdesc.get_captured pdesc) ; let method_annotation = attributes.ProcAttributes.method_annotation in if not (Annot.Method.is_empty method_annotation) then diff --git a/infer/src/biabduction/Tabulation.ml b/infer/src/biabduction/Tabulation.ml index a83c85e20..5062be8bf 100644 --- a/infer/src/biabduction/Tabulation.ml +++ b/infer/src/biabduction/Tabulation.ml @@ -1390,7 +1390,7 @@ let exe_call_postprocess tenv ret_id trace_call callee_pname callee_attrs loc re let should_add_ret_attr _ = let is_likely_getter = function | Typ.Procname.Java pn_java -> - Int.equal (List.length (Typ.Procname.Java.get_parameters pn_java)) 0 + List.is_empty (Typ.Procname.Java.get_parameters pn_java) | _ -> false in diff --git a/infer/src/checkers/uninit.ml b/infer/src/checkers/uninit.ml index a05b083f1..dd310eb0a 100644 --- a/infer/src/checkers/uninit.ml +++ b/infer/src/checkers/uninit.ml @@ -223,7 +223,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let rhs_base, al = AccessExpression.to_access_path rhs_access_expr in let uninit_vars' = D.remove lhs_ap astate.uninit_vars in let uninit_vars = - if Int.equal (List.length apl) 0 then + if List.is_empty apl then (* if we assign to the root of a struct then we need to remove all the fields *) remove_all_fields tenv (lhs_var, lhs_typ) uninit_vars' else uninit_vars' diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 599c1c1da..ae691dedc 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -552,7 +552,7 @@ let get_objc_property_accessor tenv ms = (** Creates a procedure description. *) let create_local_procdesc ?(set_objc_accessor_attr= false) trans_unit_ctx cfg tenv ms fbody captured = - let defined = not (Int.equal (List.length fbody) 0) in + let defined = not (List.is_empty fbody) in let proc_name = ms.CMethodSignature.name in let pname = Typ.Procname.to_string proc_name in let attributes = sil_func_attributes_of_attributes ms.CMethodSignature.attributes in diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index b7d7e40d7..7f2bfa4e6 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2152,7 +2152,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | None -> create_var_exp_tmp_var trans_state expr_info "SIL_init_list__" in - if Int.equal (List.length stmts) 0 then + if List.is_empty stmts then (* perform zero initialization of a primitive type, record types will have ImplicitValueInitExpr nodes *) let exps = @@ -2298,7 +2298,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s ; initd_exps= res_trans_tmp.initd_exps @ res_trans_vd.initd_exps } , Some leaf_nodes ) | _ :: var_decls' -> - (* Here we can get also record declarations or typedef declarations, which are dealt with somewhere else. + (* Here we can get also record declarations or typedef declarations, which are dealt with somewhere else. We just handle the variables here. *) collect_all_decl_inner trans_state var_decls' in diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 38806b699..6564b93d0 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -77,7 +77,7 @@ let get_exit_location source_file bytecode = let retrieve_fieldname fieldname = try let subs = Str.split (Str.regexp (Str.quote ".")) (Typ.Fieldname.to_string fieldname) in - if Int.equal (List.length subs) 0 then assert false else List.last_exn subs + List.last_exn subs with _ -> assert false