From a2c67afe6cbab294904d81ecc12ca949b9086897 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Fri, 25 Aug 2017 05:31:18 -0700 Subject: [PATCH] [threadsafety] Testing if a race that happened in a private method is reported in a caller public method. Summary: See title. Reviewed By: jberdine Differential Revision: D5697916 fbshipit-source-id: cef9eaa --- infer/tests/codetoanalyze/cpp/threadsafety/basics.cpp | 4 ++++ infer/tests/codetoanalyze/cpp/threadsafety/issues.exp | 1 + 2 files changed, 5 insertions(+) diff --git a/infer/tests/codetoanalyze/cpp/threadsafety/basics.cpp b/infer/tests/codetoanalyze/cpp/threadsafety/basics.cpp index 2f0ab5bca..03ba778ff 100644 --- a/infer/tests/codetoanalyze/cpp/threadsafety/basics.cpp +++ b/infer/tests/codetoanalyze/cpp/threadsafety/basics.cpp @@ -44,11 +44,15 @@ class Basic { int get4() { return suspiciously_read; } + int get5() { return get_private_suspiciously_read(); } + private: int well_guarded; int suspiciously_read; int suspiciously_written; int not_guarded; std::mutex mutex_; + + int get_private_suspiciously_read() { return suspiciously_read; } }; } diff --git a/infer/tests/codetoanalyze/cpp/threadsafety/issues.exp b/infer/tests/codetoanalyze/cpp/threadsafety/issues.exp index 6c9fa2616..c04cd5a0a 100644 --- a/infer/tests/codetoanalyze/cpp/threadsafety/issues.exp +++ b/infer/tests/codetoanalyze/cpp/threadsafety/issues.exp @@ -1,5 +1,6 @@ codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get2, 3, THREAD_SAFETY_VIOLATION, [,access to `suspiciously_written`,,access to `suspiciously_written`] codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get4, 0, THREAD_SAFETY_VIOLATION, [,access to `suspiciously_read`,,access to `suspiciously_read`] +codetoanalyze/cpp/threadsafety/basics.cpp, basics::Basic_get5, 0, THREAD_SAFETY_VIOLATION, [,call to basics::Basic_get_private_suspiciously_read,access to `suspiciously_read`,,access to `suspiciously_read`] codetoanalyze/cpp/threadsafety/lock_guard.cpp, basics::LockGuard_get2, 3, THREAD_SAFETY_VIOLATION, [,access to `suspiciously_written`,,access to `suspiciously_written`] codetoanalyze/cpp/threadsafety/lock_guard.cpp, basics::LockGuard_get4, 0, THREAD_SAFETY_VIOLATION, [,access to `suspiciously_read`,,access to `suspiciously_read`] codetoanalyze/cpp/threadsafety/lock_guard.cpp, basics::LockGuard_test1, 2, THREAD_SAFETY_VIOLATION, [,access to `suspiciously_read`,,access to `suspiciously_read`]