From b1e9267e08890f33ef6da8f6cea62443e88b7d94 Mon Sep 17 00:00:00 2001 From: Peter O'Hearn Date: Tue, 18 Oct 2016 13:42:57 -0700 Subject: [PATCH] [threadsafety] Don't warn autogenerated methods (containing '$' in proc name) Reviewed By: sblackshear Differential Revision: D4037106 fbshipit-source-id: 35c0a2f --- infer/src/IR/Procname.re | 7 +++++++ infer/src/IR/Procname.rei | 4 ++++ infer/src/checkers/ThreadSafety.ml | 1 + 3 files changed, 12 insertions(+) diff --git a/infer/src/IR/Procname.re b/infer/src/IR/Procname.re index c371d3ed6..be1db7de5 100644 --- a/infer/src/IR/Procname.re +++ b/infer/src/IR/Procname.re @@ -430,6 +430,13 @@ let java_is_access_method = | _ => false; +/** Check if the procedure name is of an auto-generated method containing '$'. */ +let java_is_autogen_method = + fun + | Java js => String.contains js.method_name '$' + | _ => false; + + /** Check if the proc name has the type of a java vararg. Note: currently only checks that the last argument has type Object[]. */ let java_is_vararg = diff --git a/infer/src/IR/Procname.rei b/infer/src/IR/Procname.rei index 0b334a888..1f3032311 100644 --- a/infer/src/IR/Procname.rei +++ b/infer/src/IR/Procname.rei @@ -193,6 +193,10 @@ let java_get_parameters_as_strings: java => list string; let java_is_access_method: t => bool; +/** Check if the procedure name is of an auto-generated method containing '$'. */ +let java_is_autogen_method: t => bool; + + /** Check if the procedure belongs to an anonymous inner class. */ let java_is_anonymous_inner_class: t => bool; diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index ed6b785bb..4c0bda291 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -110,6 +110,7 @@ module ResultsTableType = Map.Make (struct end) let should_analyze_proc (_,_,proc_name,proc_desc) = + not (Procname.java_is_autogen_method proc_name) && not (Procname.is_constructor proc_name) && not (Procname.is_class_initializer proc_name) && Cfg.Procdesc.get_access proc_desc <> PredSymb.Private