[all-commits] [llvm/llvm-project] c1e17e: [ThreadSafety] Ignore parameter destructors (#170843)
Utkarsh Saxena via All-commits
all-commits at lists.llvm.org
Fri Dec 5 06:59:33 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c1e17e59922b52afc548f59ed2f4e2a2121f10db
https://github.com/llvm/llvm-project/commit/c1e17e59922b52afc548f59ed2f4e2a2121f10db
Author: Utkarsh Saxena <usx at google.com>
Date: 2025-12-05 (Fri, 05 Dec 2025)
Changed paths:
M clang/lib/Analysis/ThreadSafety.cpp
M clang/test/SemaCXX/warn-thread-safety-analysis.cpp
Log Message:
-----------
[ThreadSafety] Ignore parameter destructors (#170843)
Fixes a false positive in thread safety analysis when function
parameters have lock/unlock annotations in their constructor/destructor.
PR #169320 added destructors to the CFG, which introduced false
positives in thread safety analysis for function parameters. According
to [expr.call#6](https://eel.is/c++draft/expr.call#6), parameter
initialization occurs in the caller's context while destruction occurs
in the callee's context.
```cpp
class A {
public:
A() EXCLUSIVE_LOCK_FUNCTION(mu_) { mu_.Lock(); }
~A() UNLOCK_FUNCTION(mu_) { mu_.Unlock(); }
private:
Mutex mu_;
};
int do_something(A a) { // Previously: false positive warning
return 0;
}
```
Previously, thread safety analysis would see the destructor (unlock) in
`do_something` but not the corresponding constructor (lock) that
happened in the caller's context, causing a false positive.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list