diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index 9d45c9227..b7c3c5399 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -155,7 +155,7 @@ let process_results_table tab = ( let should_analyze_file file_env = IList.exists (fun (_, tenv, pname, _) -> - AnnotationReachability.check_attributes Annotations.ia_is_thread_safe tenv pname + PatternMatch.check_class_attributes Annotations.ia_is_thread_safe tenv pname ) file_env diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index c72c0ef2b..b721f68e1 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -134,13 +134,6 @@ let is_allocator tenv pname = false let check_attributes check tenv pname = - let check_class_attributes check tenv = function - | Procname.Java java_pname -> - let check_class_annots _ { StructTyp.annots; } = check annots in - PatternMatch.supertype_exists tenv - check_class_annots - (Procname.java_get_class_type_name java_pname) - | _ -> false in let check_method_attributes check pname = match Specs.proc_resolve_attributes pname with | None -> false @@ -148,7 +141,7 @@ let check_attributes check tenv pname = let annotated_signature = Annotations.get_annotated_signature attributes in let ret_annotation, _ = annotated_signature.Annotations.ret in check ret_annotation in - 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 overrides () = diff --git a/infer/src/checkers/patternMatch.ml b/infer/src/checkers/patternMatch.ml index f1f59d925..3f47af59c 100644 --- a/infer/src/checkers/patternMatch.ml +++ b/infer/src/checkers/patternMatch.ml @@ -370,3 +370,12 @@ let is_exception tenv typename = (** Checks if the class name is a Java exception *) let is_throwable tenv typename = is_subtype_of_str tenv typename "java.lang.Throwable" + +(** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument*) +let check_class_attributes check tenv = function + | Procname.Java java_pname -> + let check_class_annots _ { StructTyp.annots; } = check annots in + supertype_exists tenv + check_class_annots + (Procname.java_get_class_type_name java_pname) + | _ -> false diff --git a/infer/src/checkers/patternMatch.mli b/infer/src/checkers/patternMatch.mli index c685b0a3d..190d9bde4 100644 --- a/infer/src/checkers/patternMatch.mli +++ b/infer/src/checkers/patternMatch.mli @@ -110,3 +110,6 @@ val is_throwable : Tenv.t -> Typename.t -> bool (** [is_runtime_exception tenv class_name] checks if classname is of type java.lang.RuntimeException *) val is_runtime_exception : Tenv.t -> Typename.t -> bool + +(** tests whether any class attributes (e.g., @ThreadSafe) pass check of first argument*) +val check_class_attributes : (Annot.Item.t -> bool) -> Tenv.t -> Procname.t -> bool