<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/143711>143711</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong source range for CXXTemporaryObjectExpr
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tJener
</td>
</tr>
</table>
<pre>
See https://godbolt.org/z/6cdcj1qqY
```c++
struct S {
S(int, int);
};
void f() {
S(S(0, 1));
}
```
When the `CXXTemporaryObjectExpr` is wrapped with a `CXXFunctionalCastExpr`, the source range of the `CXXTemporaryObjectExpr` contains the closing parenthesis of the `CXXFunctionalCastExpr`.
This occurs starting in `-std=c++17`, where guaranteed copy elision is in effect. In C++14, there is an intervening `CXXConstructExpr` and the `CXXTemporaryObjectExpr` has the correct source range (although Compiler Explorer's highlighting of AST nodes includes the closing parenthesis, as if `))` was a single token).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEU01v7CgQ_DX40soI4--DD5NJLO1e9jCRkj1i3DZkGXAAzyT765_wOHpJlKdIWGC5qrqrcHPv1WQQW1LckuIu4UuQ1rXhbzTokt4Ob-0REWQIsyfZnrCOsG6yQ2912Fk3Edb9T1hXikE8py8v_xK6j6uk1yUIu42L7n1wiwhwBFLFVwCAI2G1MoGwA6xbQ7L4iVR324Huz1YNMBJWE9Z8YcaHRm4amR_JH-pfVR4lGggSgZT08PT0gKfZOu7e_umfUYT719mRkoLycHF8nnGAiwoS-AbvFiOCsobrA_fv6Fg4Knq7OIHguJkQ7PhzFWFN4Mr4FSm09cpMMHOHJkj0yn8W-bb27urqQUa0EIvz4AN3ISopE5k3Pgwku9vST6ut4YtEhzAt3HETEAcQdn4D1Mora6J_ZQDHEUXYwV8GDhs938w6jBhu4m2hO6OJBa99Hqy5XvC7TW6Gn7OQfIvBOocifA6TsJrrIO0ySTjY06w0Orh_nbV16AirPEg1Sa0muRq3I-yPD2DsgNGH0Es8_CHkaIh7UCOsyay_T0nhwj1wiGCNEOx_aAhrdsnQZkOTNTzBNq3ypixYVhaJbKu8F9jUad30I8sz2jNB00LQMc9SVuV5olpGWUHLNE3zjOXFbmA1y6uxKnlW10XWkJziiSu90_p8iuOUKO8XbNM8q9I00bxH7dfRZExobiaS7UdnTUAzEMbiwLo2cm_6ZfIkp1r54H-rBRU0to_OmulzuKN18P29JIvT7ZdxV0Eu_U7YE2Fd1N62m9nZSCOsW9v2hHVb5-eW_QoAAP__wlJg8Q">