[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
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_annotated_functional =
has_return_annot Annotations.ia_is_functional in
@ -486,7 +482,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
astate_callee
| Some (ret_id, ret_typ) ->
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
AttributeMapDomain.add_attribute
(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
(* TODO (t15588153): clean this up *)
let is_thread_safe_method pdesc tenv =
let overrides_thread_safe_method pname tenv =
PatternMatch.override_exists
(fun pn ->
Annotations.pname_has_return_annot
pn
~attrs_of_pname:Specs.proc_resolve_attributes
Annotations.ia_is_thread_safe_method)
tenv pname in
Annotations.pdesc_return_annot_ends_with pdesc Annotations.thread_safe_method ||
overrides_thread_safe_method (Procdesc.get_proc_name pdesc) tenv in
PatternMatch.override_exists
(fun pn ->
Annotations.pname_has_return_annot
pn
~attrs_of_pname:Specs.proc_resolve_attributes
Annotations.ia_is_thread_safe_method)
tenv
(Procdesc.get_proc_name pdesc) in
let should_report ((_, tenv, _, pdesc) as proc_env) =
(should_report_on_all_procs || is_thread_safe_method pdesc tenv)
&& 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
let method_overrides is_annotated tenv pname =
is_annotated tenv pname ||
PatternMatch.override_exists (fun pn -> is_annotated tenv pn) 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
| _ ->
false in
f proc_name ||
match proc_name with
| Procname.Java proc_name_java ->
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) list
(** Return true if applying the given predicate to an override of [procname] returns [true]. Note
that this does apply the predicate to [procname] itself. For the moment, this only works for
Java *)
(** Return true if applying the given predicate to an override of [procname] or [procname] itself
returns true. For the moment, this only works for Java *)
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
predicate to [procname] itself. For the moment, this only works for Java *)
(** Apply the given predicate to procname and each override of [procname]. For the moment, this only
works for Java *)
val override_iter : (Procname.t -> unit) -> Tenv.t -> Procname.t -> unit
val type_get_annotation : Tenv.t -> Typ.t -> Annot.Item.t option

Loading…
Cancel
Save