Commit a999ab4
authored
Thread safety analysis: Fix substitution for operator calls (#116487)
For operator calls that go to methods we need to substitute the first
parameter for "this" and the following parameters into the function
parameters, instead of substituting all of them into the parameters.
This revealed an issue about lambdas. An existing test accidentally
worked because the substitution bug was covered by a speciality of
lambdas: a CXXThisExpr in a lambda CXXMethodDecl does not refer to the
implicit this argument of the method, but to a captured "this" from the
context the lambda was created in. This can happen for operator calls,
where it worked due to the substitution bug (we treated the implicit
this argument incorrectly as parameter), and for regular calls (i.e.
obj.operator()(args) instead of obj(args)), where it didn't work.
The correct fix seems to be to clear the self-argument on a lambda call.
Lambdas can only capture "this" inside methods, and calls to the lambda
in that scope cannot substitute anything for "this".1 parent c3276a9 commit a999ab4
File tree
2 files changed
+47
-2
lines changed- clang
- lib/Analysis
- test/SemaCXX
2 files changed
+47
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
140 | 148 | | |
141 | 149 | | |
142 | 150 | | |
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
146 | 162 | | |
147 | 163 | | |
148 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1593 | 1593 | | |
1594 | 1594 | | |
1595 | 1595 | | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
1596 | 1599 | | |
1597 | 1600 | | |
| 1601 | + | |
1598 | 1602 | | |
1599 | 1603 | | |
1600 | 1604 | | |
| |||
1607 | 1611 | | |
1608 | 1612 | | |
1609 | 1613 | | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1610 | 1635 | | |
1611 | 1636 | | |
1612 | 1637 | | |
| |||
5172 | 5197 | | |
5173 | 5198 | | |
5174 | 5199 | | |
| 5200 | + | |
5175 | 5201 | | |
| 5202 | + | |
5176 | 5203 | | |
5177 | 5204 | | |
| 5205 | + | |
| 5206 | + | |
5178 | 5207 | | |
5179 | 5208 | | |
5180 | 5209 | | |
| |||
0 commit comments