Replace uses of Option.value_map ~default:false with Option.exists

Reviewed By: jvillard

Differential Revision: D26423607

fbshipit-source-id: 701ee0959
master
Ezgi Çiçek 4 years ago committed by Facebook GitHub Bot
parent 1596fc7e85
commit 9a1a759638

@ -115,7 +115,7 @@ let is_freshly_captured source =
|> SqliteUtils.check_result_code db ~log:"load bind source file" ; |> SqliteUtils.check_result_code db ~log:"load bind source file" ;
SqliteUtils.result_single_column_option ~finalize:false ~log:"SourceFiles.is_freshly_captured" SqliteUtils.result_single_column_option ~finalize:false ~log:"SourceFiles.is_freshly_captured"
db load_stmt 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 () let mark_all_stale () = DBWriter.mark_all_source_files_stale ()

@ -987,8 +987,8 @@ let execute_store ?(report_deref_errors = true) ({InterproceduralAnalysis.tenv;
let is_variadic_procname callee_pname = let is_variadic_procname callee_pname =
Option.value_map ~default:false (AnalysisCallbacks.proc_resolve_attributes callee_pname) Option.exists (AnalysisCallbacks.proc_resolve_attributes callee_pname) ~f:(fun proc_attrs ->
~f:(fun proc_attrs -> proc_attrs.ProcAttributes.is_variadic) proc_attrs.ProcAttributes.is_variadic )
let resolve_and_analyze_no_dynamic_dispatch {InterproceduralAnalysis.analyze_dependency; tenv} let resolve_and_analyze_no_dynamic_dispatch {InterproceduralAnalysis.analyze_dependency; tenv}

@ -847,7 +847,7 @@ module MemPure = struct
prev next 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] *) (** Collect the location that was increased by one, i.e., [x -> x+1] *)
let get_incr_locs m = let get_incr_locs m =
@ -1204,7 +1204,7 @@ module AliasMap = struct
let has_objc_collection_size_alias : Loc.t -> t -> bool = let has_objc_collection_size_alias : Loc.t -> t -> bool =
fun loc x -> fun loc x ->
AliasTargets.find_size_alias (find_loc 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 = let load : Ident.t -> Loc.t -> AliasTarget.t -> t -> t =

@ -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 (* 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. *) its summary, we want to track it in the domain. *)
let build_exists_in_callees = let build_exists_in_callees =
Option.value_map ~default:false callee_summary_opt ~f:(fun sum -> Option.exists callee_summary_opt ~f:LithoDomain.Mem.contains_build
LithoDomain.Mem.contains_build sum )
in in
is_build_method callee_pname tenv is_build_method callee_pname tenv
|| is_create_method callee_pname tenv || is_create_method callee_pname tenv

@ -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 std_vector_reserve address memory = add_one address Attribute.StdVectorReserve memory
let is_end_of_collection address attrs = 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 = let is_std_vector_reserved address attrs =
Graph.find_opt address attrs Graph.find_opt address attrs |> Option.exists ~f:Attributes.is_std_vector_reserved
|> Option.value_map ~default:false ~f:Attributes.is_std_vector_reserved
let canonicalize ~get_var_repr attrs_map = let canonicalize ~get_var_repr attrs_map =

@ -1081,10 +1081,9 @@ module ProcNameDispatcher = struct
Config.pulse_model_return_nonnull Config.pulse_model_return_nonnull
in in
let match_regexp_opt r_opt (_tenv, proc_name) _ = 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 s = Procname.to_string proc_name in
let r = Str.string_match r s 0 in Str.string_match r s 0 )
r )
in in
let map_context_tenv f (x, _) = f x in let map_context_tenv f (x, _) = f x in
make_dispatcher make_dispatcher

@ -403,8 +403,8 @@ let prune_binop ~negated bop lhs_op rhs_op ({is_unsat; bo_itvs= _; citvs; formul
(** {2 Queries} *) (** {2 Queries} *)
let is_known_zero phi v = let is_known_zero phi v =
CItvs.find_opt v phi.citvs |> Option.value_map ~default:false ~f:CItv.is_equal_to_zero CItvs.find_opt v phi.citvs |> Option.exists ~f:CItv.is_equal_to_zero
|| BoItvs.find_opt v phi.bo_itvs |> Option.value_map ~default:false ~f:Itv.ItvPure.is_zero || BoItvs.find_opt v phi.bo_itvs |> Option.exists ~f:Itv.ItvPure.is_zero
|| Formula.is_known_zero phi.formula v || Formula.is_known_zero phi.formula v

Loading…
Cancel
Save