From 8e91932be20a7cc97149866003f2dc03dcd5b740 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Wed, 28 Jun 2017 08:01:27 -0700 Subject: [PATCH] [ThreadSafety] Do not report on private C++ methods Reviewed By: jberdine Differential Revision: D5337791 fbshipit-source-id: 7ea95ab --- infer/src/checkers/ThreadSafety.ml | 2 ++ infer/tests/codetoanalyze/cpp/threadsafety/lock_guard.cpp | 2 ++ 2 files changed, 4 insertions(+) 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; } }; }