[cleanup] make PatternMatch.override_exists check the current procname too

Reviewed By: jeremydubreil

Differential Revision: D4594441

fbshipit-source-id: 7798f29
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent 5c2ee8d85f
commit 8629ee5381

@ -194,10 +194,6 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
~attrs_of_pname:Specs.proc_resolve_attributes ~attrs_of_pname:Specs.proc_resolve_attributes
predicate predicate
(* like PatternMatch.override_exists, but also applies [predicate] to [pname] *)
let proc_or_override_exists pname tenv (predicate : Procname.t -> bool) =
predicate pname || PatternMatch.override_exists predicate tenv pname
let is_functional pname = let is_functional pname =
let is_annotated_functional = let is_annotated_functional =
has_return_annot Annotations.ia_is_functional in has_return_annot Annotations.ia_is_functional in
@ -486,7 +482,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
astate_callee astate_callee
| Some (ret_id, ret_typ) -> | Some (ret_id, ret_typ) ->
let add_if_annotated predicate attribute attribute_map = let add_if_annotated predicate attribute attribute_map =
if proc_or_override_exists callee_pname tenv predicate if PatternMatch.override_exists predicate tenv callee_pname
then then
AttributeMapDomain.add_attribute AttributeMapDomain.add_attribute
(AccessPath.of_id ret_id ret_typ) attribute attribute_map (AccessPath.of_id ret_id ret_typ) attribute attribute_map
@ -834,16 +830,14 @@ let process_results_table file_env tab =
let should_report_on_all_procs = should_report_on_file file_env in let should_report_on_all_procs = should_report_on_file file_env in
(* TODO (t15588153): clean this up *) (* TODO (t15588153): clean this up *)
let is_thread_safe_method pdesc tenv = let is_thread_safe_method pdesc tenv =
let overrides_thread_safe_method pname tenv =
PatternMatch.override_exists PatternMatch.override_exists
(fun pn -> (fun pn ->
Annotations.pname_has_return_annot Annotations.pname_has_return_annot
pn pn
~attrs_of_pname:Specs.proc_resolve_attributes ~attrs_of_pname:Specs.proc_resolve_attributes
Annotations.ia_is_thread_safe_method) Annotations.ia_is_thread_safe_method)
tenv pname in tenv
Annotations.pdesc_return_annot_ends_with pdesc Annotations.thread_safe_method || (Procdesc.get_proc_name pdesc) in
overrides_thread_safe_method (Procdesc.get_proc_name pdesc) tenv in
let should_report ((_, tenv, _, pdesc) as proc_env) = let should_report ((_, tenv, _, pdesc) as proc_env) =
(should_report_on_all_procs || is_thread_safe_method pdesc tenv) (should_report_on_all_procs || is_thread_safe_method pdesc tenv)
&& should_report_on_proc proc_env in && should_report_on_proc proc_env in

@ -140,7 +140,6 @@ let check_attributes check tenv pname =
Annotations.pname_has_return_annot pname ~attrs_of_pname:Specs.proc_resolve_attributes check Annotations.pname_has_return_annot pname ~attrs_of_pname:Specs.proc_resolve_attributes check
let method_overrides is_annotated tenv pname = let method_overrides is_annotated tenv pname =
is_annotated tenv pname ||
PatternMatch.override_exists (fun pn -> is_annotated tenv pn) tenv pname PatternMatch.override_exists (fun pn -> is_annotated tenv pn) tenv pname
let method_has_annot annot tenv pname = let method_has_annot annot tenv pname =

@ -343,6 +343,8 @@ let override_exists f tenv proc_name =
List.exists ~f:(super_type_exists tenv) supers List.exists ~f:(super_type_exists tenv) supers
| _ -> | _ ->
false in false in
f proc_name ||
match proc_name with match proc_name with
| Procname.Java proc_name_java -> | Procname.Java proc_name_java ->
let type_name = Typename.Java.from_string (Procname.java_get_class_name proc_name_java) in let type_name = Typename.Java.from_string (Procname.java_get_class_name proc_name_java) in

@ -82,13 +82,12 @@ val proc_calls :
(Procname.t -> ProcAttributes.t -> bool) -> (Procname.t -> ProcAttributes.t -> bool) ->
(Procname.t * ProcAttributes.t) list (Procname.t * ProcAttributes.t) list
(** Return true if applying the given predicate to an override of [procname] returns [true]. Note (** Return true if applying the given predicate to an override of [procname] or [procname] itself
that this does apply the predicate to [procname] itself. For the moment, this only works for returns true. For the moment, this only works for Java *)
Java *)
val override_exists : (Procname.t -> bool) -> Tenv.t -> Procname.t -> bool val override_exists : (Procname.t -> bool) -> Tenv.t -> Procname.t -> bool
(** Apply the given predicate to each override of [procname]. Notet hat this does apply the (** Apply the given predicate to procname and each override of [procname]. For the moment, this only
predicate to [procname] itself. For the moment, this only works for Java *) works for Java *)
val override_iter : (Procname.t -> unit) -> Tenv.t -> Procname.t -> unit val override_iter : (Procname.t -> unit) -> Tenv.t -> Procname.t -> unit
val type_get_annotation : Tenv.t -> Typ.t -> Annot.Item.t option val type_get_annotation : Tenv.t -> Typ.t -> Annot.Item.t option

Loading…
Cancel
Save