From fedb8e5136afb6e932947097e3e3f3a1ff7ad5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Tue, 18 Jun 2019 01:41:48 -0700 Subject: [PATCH] [infer] Cleanup preanalysis Summary: Preanalysis is performed at the frontend now. Hence, we don't need to repeatedly check/set when/if it is performed. Reviewed By: mbouaziz Differential Revision: D15863175 fbshipit-source-id: f9c6b7ae1 --- infer/src/IR/ProcAttributes.ml | 4 ---- infer/src/IR/ProcAttributes.mli | 1 - infer/src/IR/Procdesc.ml | 5 ----- infer/src/IR/Procdesc.mli | 6 ------ infer/src/backend/preanal.ml | 21 ++++++++------------- 5 files changed, 8 insertions(+), 29 deletions(-) diff --git a/infer/src/IR/ProcAttributes.ml b/infer/src/IR/ProcAttributes.ml index cb577d5e7..4a2c432a3 100644 --- a/infer/src/IR/ProcAttributes.ml +++ b/infer/src/IR/ProcAttributes.ml @@ -40,7 +40,6 @@ let pp_var_data fmt {name; typ; modify_in_block} = type t = { access: PredSymb.access (** visibility access *) ; captured: (Mangled.t * Typ.t) list (** name and type of variables captured in blocks *) - ; mutable did_preanalysis: bool (** true if we performed preanalysis on the CFG for this proc *) ; exceptions: string list (** exceptions thrown by the procedure *) ; formals: (Mangled.t * Typ.t) list (** name and type of formal parameters *) ; const_formals: int list (** list of indices of formals that are const-qualified *) @@ -67,7 +66,6 @@ type t = let default translation_unit proc_name = { access= PredSymb.Default ; captured= [] - ; did_preanalysis= false ; exceptions= [] ; formals= [] ; const_formals= [] @@ -99,7 +97,6 @@ let pp_parameters = let pp f ({ access ; captured - ; did_preanalysis ; exceptions ; formals ; const_formals @@ -147,7 +144,6 @@ let pp f F.fprintf f "; func_attributes= [@[%a@]]@," (Pp.semicolon_seq ~print_env:Pp.text_break PredSymb.pp_func_attribute) func_attributes ; - pp_bool_default ~default:default.did_preanalysis "did_preanalysis" did_preanalysis f () ; pp_bool_default ~default:default.is_abstract "is_abstract" is_abstract f () ; pp_bool_default ~default:default.is_bridge_method "is_bridge_method" is_bridge_method f () ; pp_bool_default ~default:default.is_defined "is_defined" is_defined f () ; diff --git a/infer/src/IR/ProcAttributes.mli b/infer/src/IR/ProcAttributes.mli index 1896791af..b8df10d15 100644 --- a/infer/src/IR/ProcAttributes.mli +++ b/infer/src/IR/ProcAttributes.mli @@ -23,7 +23,6 @@ type var_data = type t = { access: PredSymb.access (** visibility access *) ; captured: (Mangled.t * Typ.t) list (** name and type of variables captured in blocks *) - ; mutable did_preanalysis: bool (** true if we performed preanalysis on the CFG for this proc *) ; exceptions: string list (** exceptions thrown by the procedure *) ; formals: (Mangled.t * Typ.t) list (** name and type of formal parameters *) ; const_formals: int list (** list of indices of formals that are const-qualified *) diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index 9844c7aac..5f02d94c8 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -471,11 +471,6 @@ let compute_distance_to_exit_node pdesc = mark_distance 0 [exit_node] -(** check or indicate if we have performed preanalysis on the CFG *) -let did_preanalysis pdesc = pdesc.attributes.did_preanalysis - -let signal_did_preanalysis pdesc = pdesc.attributes.did_preanalysis <- true - let get_attributes pdesc = pdesc.attributes let set_attributes pdesc attributes = pdesc.attributes <- attributes diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index 9956beecc..8b2dfbbca 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -206,9 +206,6 @@ val create_node : t -> Location.t -> Node.nodekind -> Sil.instr list -> Node.t val create_node_from_not_reversed : t -> Location.t -> Node.nodekind -> Instrs.not_reversed_t -> Node.t -val did_preanalysis : t -> bool -(** true if we ran the preanalysis on the CFG associated with [t] *) - val fold_instrs : t -> init:'accum -> f:('accum -> Node.t -> Sil.instr -> 'accum) -> 'accum (** fold over all nodes and their instructions *) @@ -296,9 +293,6 @@ val set_exit_node : t -> Node.t -> unit val set_start_node : t -> Node.t -> unit -val signal_did_preanalysis : t -> unit -(** indicate that we have performed preanalysis on the CFG associated with [t] *) - val get_wto : t -> Node.t WeakTopologicalOrder.Partition.t val is_loop_head : t -> Node.t -> bool diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index 6519d176a..48c28fa8b 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -195,16 +195,12 @@ let do_liveness pdesc tenv = let liveness_inv_map = LivenessAnalysis.exec_cfg liveness_proc_cfg (ProcData.make_default pdesc tenv) ~initial in - add_nullify_instrs pdesc tenv liveness_inv_map ; - Procdesc.signal_did_preanalysis pdesc + add_nullify_instrs pdesc tenv liveness_inv_map (** add Abstract instructions into the IR to give hints about when abstraction should be performed *) -let do_abstraction pdesc = - add_abstraction_instructions pdesc ; - Procdesc.signal_did_preanalysis pdesc - +let do_abstraction pdesc = add_abstraction_instructions pdesc let do_funptr_sub pdesc tenv = let updated = FunctionPointers.substitute_function_pointers pdesc tenv in @@ -212,10 +208,9 @@ let do_funptr_sub pdesc tenv = let do_preanalysis pdesc tenv = - if not (Procdesc.did_preanalysis pdesc) then ( - if - Config.function_pointer_specialization - && not (Typ.Procname.is_java (Procdesc.get_proc_name pdesc)) - then do_funptr_sub pdesc tenv ; - do_liveness pdesc tenv ; - do_abstraction pdesc ) + if + Config.function_pointer_specialization + && not (Typ.Procname.is_java (Procdesc.get_proc_name pdesc)) + then do_funptr_sub pdesc tenv ; + do_liveness pdesc tenv ; + do_abstraction pdesc