[libcxx-commits] [clang] [libcxx] [clang][ThreadSafety] Handle mutex scope (PR #157171)
Aaron Puchert via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 7 13:44:12 PDT 2025
================
@@ -2443,6 +2443,22 @@ void ThreadSafetyAnalyzer::intersectAndWarn(FactSet &EntrySet,
if (join(FactMan[*EntryIt], ExitFact, JoinLoc, EntryLEK))
*EntryIt = Fact;
} else if (!ExitFact.managed() || EntryLEK == LEK_LockedAtEndOfFunction) {
+ if (EntryLEK == LEK_LockedAtEndOfFunction) {
+ const til::SExpr *Sexp = ExitFact.sexpr();
+ const VarDecl *MutexVar = nullptr;
+
+ if (const auto *Proj = dyn_cast<til::Project>(Sexp)) {
+ if (const auto *Base = dyn_cast<til::LiteralPtr>(Proj->record()))
+ MutexVar = dyn_cast_or_null<VarDecl>(Base->clangDecl());
+ } else if (const auto *LP = dyn_cast<til::LiteralPtr>(Sexp)) {
+ MutexVar = dyn_cast_or_null<VarDecl>(LP->clangDecl());
+ }
----------------
aaronpuchert wrote:
Scoped lockables should be unlocked by the automatic destructor. I don't think we should add this code.
https://github.com/llvm/llvm-project/pull/157171
More information about the libcxx-commits
mailing list