[cleanup] restrict uses of annotated_signature to eradicate

Summary:
One of the things that confuses me about the current annotations API is that there's a lot of ways to do the same thing.
Some of the concepts like `annotated_signature` are only really needed by Eradicate.
This diff removes usages of `annotated_signature` outside of Eradicate (everyone else was just using `get_annotated_signature` as a roundabout way to get the return annotation of a procedure).
In the future, I'll move `get_annotated_signature` and other Eradicate-specific functionality into its own module inside the Eradicate directory.

Reviewed By: jberdine

Differential Revision: D4472058

fbshipit-source-id: 5bb0846
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent b3e9eedd59
commit bcfcb5d405

@ -775,10 +775,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
let enforce_guarded_access_ accessed_fld guarded_by_str prop = let enforce_guarded_access_ accessed_fld guarded_by_str prop =
(* return true if [pdesc] has an annotation that matches [guarded_by_str] *) (* return true if [pdesc] has an annotation that matches [guarded_by_str] *)
let proc_has_matching_annot pdesc guarded_by_str = let proc_has_matching_annot pdesc guarded_by_str =
let proc_signature = match extract_guarded_by_str (Annotations.pdesc_get_return_annot pdesc) with
Annotations.get_annotated_signature (Procdesc.get_attributes pdesc) in
let proc_annot, _ = proc_signature.Annotations.ret in
match extract_guarded_by_str proc_annot with
| Some proc_guarded_by_str -> | Some proc_guarded_by_str ->
(* the lock is not held, but the procedure is annotated with @GuardedBy *) (* the lock is not held, but the procedure is annotated with @GuardedBy *)
String.equal proc_guarded_by_str guarded_by_str String.equal proc_guarded_by_str guarded_by_str
@ -817,10 +814,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
String.equal "itself" (String.lowercase guarded_by_str) || String.equal "itself" (String.lowercase guarded_by_str) ||
String.is_suffix ~suffix:guarded_by_str (Ident.fieldname_to_string accessed_fld) in String.is_suffix ~suffix:guarded_by_str (Ident.fieldname_to_string accessed_fld) in
let proc_has_suppress_guarded_by_annot pdesc = let proc_has_suppress_guarded_by_annot pdesc =
let proc_signature = match extract_suppress_warnings_str (Annotations.pdesc_get_return_annot pdesc) with
Annotations.get_annotated_signature (Procdesc.get_attributes pdesc) in
let proc_annot, _ = proc_signature.Annotations.ret in
match extract_suppress_warnings_str proc_annot with
| Some suppression_str-> | Some suppression_str->
String.equal suppression_str "InvalidAccessToGuardedField" String.equal suppression_str "InvalidAccessToGuardedField"
| None -> false in | None -> false in

@ -52,12 +52,9 @@ let log_issue
?session ?session
?ltr ?ltr
exn = exn =
let should_suppress_lint summary = let should_suppress_lint (summary : Specs.summary) =
Config.curr_language_is Config.Java && Config.curr_language_is Config.Java &&
let annotated_signature = Annotations.ia_is_suppress_lint (fst summary.attributes.ProcAttributes.method_annotation) in
Annotations.get_annotated_signature summary.Specs.attributes in
let ret_annotation, _ = annotated_signature.Annotations.ret in
Annotations.ia_is_suppress_lint ret_annotation in
match Specs.get_summary proc_name with match Specs.get_summary proc_name with
| Some summary when should_suppress_lint summary -> () | Some summary when should_suppress_lint summary -> ()
| Some summary -> | Some summary ->

@ -596,10 +596,7 @@ let process_results_table file_env tab =
let check_method_attributes check pname = let check_method_attributes check pname =
match Specs.proc_resolve_attributes pname with match Specs.proc_resolve_attributes pname with
| None -> false | None -> false
| Some attributes -> | Some attributes -> check (fst attributes.ProcAttributes.method_annotation) in
let annotated_signature = Annotations.get_annotated_signature attributes in
let ret_annotation, _ = annotated_signature.Annotations.ret in
check ret_annotation in
let found = ref false in let found = ref false in
PatternMatch.proc_iter_overridden_methods PatternMatch.proc_iter_overridden_methods
(fun pn -> (fun pn ->

@ -130,10 +130,7 @@ let check_attributes check tenv pname =
let check_method_attributes check pname = let check_method_attributes check pname =
match Specs.proc_resolve_attributes pname with match Specs.proc_resolve_attributes pname with
| None -> false | None -> false
| Some attributes -> | Some attributes -> check (fst attributes.ProcAttributes.method_annotation) in
let annotated_signature = Annotations.get_annotated_signature attributes in
let ret_annotation, _ = annotated_signature.Annotations.ret in
check ret_annotation in
PatternMatch.check_class_attributes check tenv pname || check_method_attributes check pname PatternMatch.check_class_attributes check tenv pname || check_method_attributes check pname
let method_overrides is_annotated tenv pname = let method_overrides is_annotated tenv pname =

@ -98,9 +98,11 @@ let pdesc_has_parameter_annot pdesc predicate =
let _, param_annotations = (Procdesc.get_attributes pdesc).ProcAttributes.method_annotation in let _, param_annotations = (Procdesc.get_attributes pdesc).ProcAttributes.method_annotation in
IList.exists predicate param_annotations IList.exists predicate param_annotations
let pdesc_get_return_annot pdesc =
fst (Procdesc.get_attributes pdesc).ProcAttributes.method_annotation
let pdesc_has_return_annot pdesc predicate = let pdesc_has_return_annot pdesc predicate =
let return_annotation, _ = (Procdesc.get_attributes pdesc).ProcAttributes.method_annotation in predicate (pdesc_get_return_annot pdesc)
predicate return_annotation
let pdesc_return_annot_ends_with pdesc annot = let pdesc_return_annot_ends_with pdesc annot =
pdesc_has_return_annot pdesc (fun ia -> ia_ends_with ia annot) pdesc_has_return_annot pdesc (fun ia -> ia_ends_with ia annot)

@ -119,6 +119,9 @@ val ia_is_volatile : Annot.Item.t -> bool
parameters *) parameters *)
val pdesc_has_parameter_annot : Procdesc.t -> (Annot.Item.t -> bool) -> bool val pdesc_has_parameter_annot : Procdesc.t -> (Annot.Item.t -> bool) -> bool
(** get the list of annotations on the return value of [pdesc] *)
val pdesc_get_return_annot : Procdesc.t -> Annot.Item.t
(** return true if the given predicate evaluates to true on the annotation of [pdesc]'s return (** return true if the given predicate evaluates to true on the annotation of [pdesc]'s return
value *) value *)
val pdesc_has_return_annot : Procdesc.t -> (Annot.Item.t -> bool) -> bool val pdesc_has_return_annot : Procdesc.t -> (Annot.Item.t -> bool) -> bool

Loading…
Cancel
Save