From 0d0b3d2eb47599dcd526f6e2b401b0097259b1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Mon, 30 Nov 2020 01:04:51 -0800 Subject: [PATCH] [impurity] Hoist out formals and procname Reviewed By: ngorogiannis Differential Revision: D25185595 fbshipit-source-id: 801e21fbe --- infer/src/checkers/impurity.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/infer/src/checkers/impurity.ml b/infer/src/checkers/impurity.ml index a5e16ff3b..ed2c4fe2b 100644 --- a/infer/src/checkers/impurity.ml +++ b/infer/src/checkers/impurity.ml @@ -137,7 +137,7 @@ let is_modeled_pure tenv pname = (** Given Pulse summary, extract impurity info, i.e. parameters and global variables that are modified by the function and skipped functions. *) -let extract_impurity tenv pdesc (exec_state : ExecutionDomain.t) : ImpurityDomain.t = +let extract_impurity tenv pname formals (exec_state : ExecutionDomain.t) : ImpurityDomain.t = let astate, exited = match exec_state with | ExitProgram astate -> @@ -150,10 +150,7 @@ let extract_impurity tenv pdesc (exec_state : ExecutionDomain.t) : ImpurityDomai let pre_heap = (AbductiveDomain.get_pre astate).BaseDomain.heap in let post = AbductiveDomain.get_post astate in let post_stack = post.BaseDomain.stack in - let pname = Procdesc.get_proc_name pdesc in - let modified_params = - Procdesc.get_formals pdesc |> get_modified_params pname post_stack pre_heap post - in + let modified_params = get_modified_params pname post_stack pre_heap post formals in let modified_globals = get_modified_globals pre_heap post post_stack in let skipped_calls = SkippedCalls.filter @@ -184,10 +181,13 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} Reporting.log_issue proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr] Impurity IssueType.impure_function impure_fun_desc | Some pre_posts -> + let formals = Procdesc.get_formals proc_desc in let (ImpurityDomain.{modified_globals; modified_params; skipped_calls} as impurity_astate) = List.fold pre_posts ~init:ImpurityDomain.pure ~f:(fun acc (exec_state : ExecutionDomain.summary) -> - let modified = extract_impurity tenv proc_desc (exec_state :> ExecutionDomain.t) in + let modified = + extract_impurity tenv proc_name formals (exec_state :> ExecutionDomain.t) + in ImpurityDomain.join acc modified ) in if PurityChecker.should_report proc_name && not (ImpurityDomain.is_pure impurity_astate) then