<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/71292>71292</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[FR] clang-tidy check for exception re-throwing
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
FalcoGer
</td>
</tr>
</table>
<pre>
Rethrowing exceptions with the exception parameter creates a copy of the exception and it should be avoided in favor of just using throw.
```c++
void f()
{
throw MyExpensiveExceptionType();
}
void g()
{
try
{
f();
}
catch (const MyExpensiveExceptionType& ex)
{
// throw ex;
// ~~
// ^ Re-throwing exception arguments causes a copy to be made
// Fix:
throw;
}
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U01vozwQ_jXmMkoEw1d84NAo5T29l2r_gDEDuAsY2SYNl_72FQRC1HYXWWB5_Hz4GSysVXVPlLH4zOKLJ0bXaJPlopX6PzJeocspeyPXGP2h-hroJmlwSvcWPpRrwDW0r8EgjOjIkQFpSDiyIEDqYQJdfdkp-hKUA9vosS2hIBBXrUoqQfVQias2M-R9tA5GO-suBo7MvzD_ZX0n_n1Ihud5LKszC1QMTwz5ui9dS3Angf-n19tAvVVXet38_JoGWkHhecNdnuUW4vpnYmemTeJJDR4-wvNevmxTKZxsgOFJ6t66f7hKgG4P0S8KDHOG-Xowuj0pPWr35_PzLwUWv8IbHb43GISpx456Z0GK0e69dHruVydK-kaZqxsLX7ZUZsqfzr5PthZ6ZRaWPOTCoyxIOA8w9SP0mixJyiQ-pWmAVZBiGgZhFWKSRAGPBeey8lSGPoZB4EcBjyIfj6EIyZe8OCU8TgrOWeRTJ1R7bNtrd9Sm9pS1I2VpgBy9VhTU2uXnR5St6OuDU-XEEOfLYLIZdCjG2rLIb5V1dqdxyrXLtcnfWHyBHQyyIfkbKm2ewjR7xN5o2qxxbrBzVktwtXLNWByl7hjms8L6OQxGv5N0DPPFtWWYL8b_BAAA__9q0Rlx">