diff --git a/infer/src/checkers/liveness.ml b/infer/src/checkers/liveness.ml index 83e94bdbc..02a458180 100644 --- a/infer/src/checkers/liveness.ml +++ b/infer/src/checkers/liveness.ml @@ -104,10 +104,17 @@ let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary = let matcher_scope_guard = QualifiedCppName.Match.of_fuzzy_qual_names [ (* C++ *) - "folly::RWSpinLock::ReadHolder" + "faiss::ScopeDeleter" + ; "folly::RWSpinLock::ReadHolder" ; "folly::RWSpinLock::WriteHolder" - ; "folly::SpinLockGuard" ; "folly::ScopeGuard" + ; "folly::SharedMutex::ReadHolder" + ; "folly::SharedMutex::WriteHolder" + ; "folly::SharedMutexReadPriority::ReadHolder" + ; "folly::SharedMutexReadPriority::WriteHolder" + ; "folly::SharedMutexWritePriority::ReadHolder" + ; "folly::SharedMutexWritePriority::WriteHolder" + ; "folly::SpinLockGuard" ; "std::lock_guard" ; "std::scoped_lock" ; "std::unique_lock" (* Obj-C *) @@ -162,4 +169,3 @@ let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary = in List.iter (CFG.nodes cfg) ~f:report_on_node ; summary - diff --git a/infer/tests/codetoanalyze/cpp/liveness/dead_stores.cpp b/infer/tests/codetoanalyze/cpp/liveness/dead_stores.cpp index 483fc8c01..b1daa7f51 100644 --- a/infer/tests/codetoanalyze/cpp/liveness/dead_stores.cpp +++ b/infer/tests/codetoanalyze/cpp/liveness/dead_stores.cpp @@ -13,6 +13,13 @@ namespace folly { class ScopeGuard {}; + +class SharedMutex { + public: + class ReadHolder {}; + class WriteHolder {}; +}; + } // namespace folly namespace dead_stores { @@ -287,9 +294,13 @@ int* sentinel_ptr_ok(int* j) { void scope_guard_ok() { // realistically, it would be something like guard = folly::makeGuard(); - folly::ScopeGuard* guard = nullptr; + folly::ScopeGuard guard; } +void read_holder_ok() { folly::SharedMutex::ReadHolder guard; } + +void write_holder_ok() { folly::SharedMutex::WriteHolder guard; } + struct S { ~S() {} }; diff --git a/infer/tests/codetoanalyze/cpp/liveness/issues.exp b/infer/tests/codetoanalyze/cpp/liveness/issues.exp index 3bf2ae202..735dd1099 100644 --- a/infer/tests/codetoanalyze/cpp/liveness/issues.exp +++ b/infer/tests/codetoanalyze/cpp/liveness/issues.exp @@ -6,7 +6,7 @@ codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::dead_then_live_bad, 1, codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::easy_bad, 0, DEAD_STORE, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::init_capture_no_call_bad, 1, DEAD_STORE, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::init_capture_reassign_bad, 1, DEAD_STORE, [Write of unused value] -codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::lambda_bad::lambda_dead_stores.cpp:153:11_operator(), 1, DEAD_STORE, [Write of unused value] +codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::lambda_bad::lambda_dead_stores.cpp:160:11_operator(), 1, DEAD_STORE, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus1_bad, 2, DEAD_STORE, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus2_bad, 2, DEAD_STORE, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus3_bad, 2, DEAD_STORE, [Write of unused value]