diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index ab43c8112..f1a9aa8c7 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -1381,6 +1381,8 @@ let report_unsafe_accesses aggregated_access_map = is_class_threadsafe) && should_report_on_proc pdesc tenv | ObjC_Cpp objc_cpp -> + (* do not report if a procedure is private *) + Procdesc.get_access pdesc <> PredSymb.Private && (* report if the class has a mutex member *) class_has_mutex_member objc_cpp tenv | _ -> diff --git a/infer/tests/codetoanalyze/cpp/threadsafety/lock_guard.cpp b/infer/tests/codetoanalyze/cpp/threadsafety/lock_guard.cpp index 5c474b01c..e0524efa6 100644 --- a/infer/tests/codetoanalyze/cpp/threadsafety/lock_guard.cpp +++ b/infer/tests/codetoanalyze/cpp/threadsafety/lock_guard.cpp @@ -52,5 +52,7 @@ class LockGuard { int suspiciously_written; int not_guarded; std::mutex mutex_; + + int test2() { return suspiciously_read; } }; }