Commit dafe84f
[ThreadSafety] Ignore parameter destructors (llvm#170843)
Fixes a false positive in thread safety analysis when function
parameters have lock/unlock annotations in their constructor/destructor.
PR llvm#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.1 parent 9610854 commit dafe84f
File tree
2 files changed
+44
-0
lines changed- clang
- lib/Analysis
- test/SemaCXX
2 files changed
+44
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
2659 | 2660 | | |
2660 | 2661 | | |
2661 | 2662 | | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
2662 | 2669 | | |
2663 | 2670 | | |
2664 | 2671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1849 | 1849 | | |
1850 | 1850 | | |
1851 | 1851 | | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
1852 | 1889 | | |
1853 | 1890 | | |
1854 | 1891 | | |
| |||
0 commit comments