From 9a1a759638d14277a387c0d67286151e3349bc95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Fri, 12 Feb 2021 06:36:41 -0800 Subject: [PATCH] Replace uses of Option.value_map ~default:false with Option.exists Reviewed By: jvillard Differential Revision: D26423607 fbshipit-source-id: 701ee0959 --- infer/src/IR/SourceFiles.ml | 2 +- infer/src/biabduction/SymExec.ml | 4 ++-- infer/src/bufferoverrun/bufferOverrunDomain.ml | 4 ++-- infer/src/checkers/RequiredProps.ml | 3 +-- infer/src/pulse/PulseBaseAddressAttributes.ml | 5 ++--- infer/src/pulse/PulseModels.ml | 5 ++--- infer/src/pulse/PulsePathCondition.ml | 4 ++-- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/infer/src/IR/SourceFiles.ml b/infer/src/IR/SourceFiles.ml index 3eea1f294..b369af6cf 100644 --- a/infer/src/IR/SourceFiles.ml +++ b/infer/src/IR/SourceFiles.ml @@ -115,7 +115,7 @@ let is_freshly_captured source = |> SqliteUtils.check_result_code db ~log:"load bind source file" ; SqliteUtils.result_single_column_option ~finalize:false ~log:"SourceFiles.is_freshly_captured" db load_stmt - |> Option.value_map ~default:false ~f:deserialize_freshly_captured ) + |> Option.exists ~f:deserialize_freshly_captured ) let mark_all_stale () = DBWriter.mark_all_source_files_stale () diff --git a/infer/src/biabduction/SymExec.ml b/infer/src/biabduction/SymExec.ml index 1096b6c81..382b8fe31 100644 --- a/infer/src/biabduction/SymExec.ml +++ b/infer/src/biabduction/SymExec.ml @@ -987,8 +987,8 @@ let execute_store ?(report_deref_errors = true) ({InterproceduralAnalysis.tenv; let is_variadic_procname callee_pname = - Option.value_map ~default:false (AnalysisCallbacks.proc_resolve_attributes callee_pname) - ~f:(fun proc_attrs -> proc_attrs.ProcAttributes.is_variadic) + Option.exists (AnalysisCallbacks.proc_resolve_attributes callee_pname) ~f:(fun proc_attrs -> + proc_attrs.ProcAttributes.is_variadic ) let resolve_and_analyze_no_dynamic_dispatch {InterproceduralAnalysis.analyze_dependency; tenv} diff --git a/infer/src/bufferoverrun/bufferOverrunDomain.ml b/infer/src/bufferoverrun/bufferOverrunDomain.ml index 9a0356e78..fdcee2e50 100644 --- a/infer/src/bufferoverrun/bufferOverrunDomain.ml +++ b/infer/src/bufferoverrun/bufferOverrunDomain.ml @@ -847,7 +847,7 @@ module MemPure = struct prev next - let is_rep_multi_loc l m = Option.value_map ~default:false (find_opt l m) ~f:MVal.get_rep_multi + let is_rep_multi_loc l m = Option.exists (find_opt l m) ~f:MVal.get_rep_multi (** Collect the location that was increased by one, i.e., [x -> x+1] *) let get_incr_locs m = @@ -1204,7 +1204,7 @@ module AliasMap = struct let has_objc_collection_size_alias : Loc.t -> t -> bool = fun loc x -> AliasTargets.find_size_alias (find_loc loc x) - |> Option.value_map ~default:false ~f:Loc.is_objc_collection_internal_array + |> Option.exists ~f:Loc.is_objc_collection_internal_array let load : Ident.t -> Loc.t -> AliasTarget.t -> t -> t = diff --git a/infer/src/checkers/RequiredProps.ml b/infer/src/checkers/RequiredProps.ml index bd7b954cc..27ad8e79c 100644 --- a/infer/src/checkers/RequiredProps.ml +++ b/infer/src/checkers/RequiredProps.ml @@ -162,8 +162,7 @@ let satisfies_heuristic ~callee_pname ~callee_summary_opt tenv = (* If the method is build() or create() itself or doesn't contain a build() in its summary, we want to track it in the domain. *) let build_exists_in_callees = - Option.value_map ~default:false callee_summary_opt ~f:(fun sum -> - LithoDomain.Mem.contains_build sum ) + Option.exists callee_summary_opt ~f:LithoDomain.Mem.contains_build in is_build_method callee_pname tenv || is_create_method callee_pname tenv diff --git a/infer/src/pulse/PulseBaseAddressAttributes.ml b/infer/src/pulse/PulseBaseAddressAttributes.ml index 813af70c3..cf7894898 100644 --- a/infer/src/pulse/PulseBaseAddressAttributes.ml +++ b/infer/src/pulse/PulseBaseAddressAttributes.ml @@ -153,12 +153,11 @@ let get_must_be_initialized = get_attribute Attributes.get_must_be_initialized let std_vector_reserve address memory = add_one address Attribute.StdVectorReserve memory let is_end_of_collection address attrs = - Graph.find_opt address attrs |> Option.value_map ~default:false ~f:Attributes.is_end_of_collection + Graph.find_opt address attrs |> Option.exists ~f:Attributes.is_end_of_collection let is_std_vector_reserved address attrs = - Graph.find_opt address attrs - |> Option.value_map ~default:false ~f:Attributes.is_std_vector_reserved + Graph.find_opt address attrs |> Option.exists ~f:Attributes.is_std_vector_reserved let canonicalize ~get_var_repr attrs_map = diff --git a/infer/src/pulse/PulseModels.ml b/infer/src/pulse/PulseModels.ml index 878581df0..e05eefab4 100644 --- a/infer/src/pulse/PulseModels.ml +++ b/infer/src/pulse/PulseModels.ml @@ -1081,10 +1081,9 @@ module ProcNameDispatcher = struct Config.pulse_model_return_nonnull in let match_regexp_opt r_opt (_tenv, proc_name) _ = - Option.value_map ~default:false r_opt ~f:(fun r -> + Option.exists r_opt ~f:(fun r -> let s = Procname.to_string proc_name in - let r = Str.string_match r s 0 in - r ) + Str.string_match r s 0 ) in let map_context_tenv f (x, _) = f x in make_dispatcher diff --git a/infer/src/pulse/PulsePathCondition.ml b/infer/src/pulse/PulsePathCondition.ml index 0f7052d68..77d5e2ded 100644 --- a/infer/src/pulse/PulsePathCondition.ml +++ b/infer/src/pulse/PulsePathCondition.ml @@ -403,8 +403,8 @@ let prune_binop ~negated bop lhs_op rhs_op ({is_unsat; bo_itvs= _; citvs; formul (** {2 Queries} *) let is_known_zero phi v = - CItvs.find_opt v phi.citvs |> Option.value_map ~default:false ~f:CItv.is_equal_to_zero - || BoItvs.find_opt v phi.bo_itvs |> Option.value_map ~default:false ~f:Itv.ItvPure.is_zero + CItvs.find_opt v phi.citvs |> Option.exists ~f:CItv.is_equal_to_zero + || BoItvs.find_opt v phi.bo_itvs |> Option.exists ~f:Itv.ItvPure.is_zero || Formula.is_known_zero phi.formula v