<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/153247>153247</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Whitelist shared-state types in redudant-copy performance checks
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
oracle-9
</td>
</tr>
</table>
<pre>
Currently, the checks [`performance-unnecessary-copy-initialization`](https://clang.llvm.org/extra/clang-tidy/checks/performance/unnecessary-copy-initialization.html) and [`performance-unnecessary-value-param`](https://clang.llvm.org/extra/clang-tidy/checks/performance/unnecessary-value-param.html) are also triggered when shared-state objects (such as `shared_future`, `shared_ptr`, `stop_source`, `stop_token`, and `weak_ptr`) are passed or copied by value, recommending to pass them by reference instead.
However, passing these types by value is generally necessary to share ownership. Using references instead risks dangling lifetimes, such as when the callee outlives the caller or when all other owners are destroyed except the one holding a mistaken reference.
Consequently, (at least) the aforementioned types should be added to `performance-unnecessary-copy-initialization.AllowedTypes` and `performance-unnecessary-value-param.AllowedTypes` by default.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VM2O8zYMfBrlQiRwlDg_Bx-2uwj6AC16_EBLjK1GllyRTj736Qtps9l87WHbQ09BaA6HHHGIzK4LRI2qf1L12wIn6WNqYkLjaXlctNHOzeuUEgXxs9KvID2B6clcGDJmV42UzjENGAwtpxDIEDOmeWniOC9dcOLQuz9RXAxqV6n6TelDLzKy2rwofVL6ZDyGbuX9dVjF1Cl9ou-S8OPDUpyd859CqvTpiVDp0xeUq14Gr_QRMNgvGr6in2g5YsLh_270ieqzwUSAniNIcl1HiSzcegrAPSaySxYUgtj-TkYYlD7wZHpABrWr3lO-nSeZEuXe9etTeJT0FJM4fuM4JUN_C0q8ULjHili76kZ4ecDfOxyRmSzEBCaOjiy0M5RpMiyRicNAwbrQgcSSnBdmyFmJzpQoGAIXWAjtSlUvqnr5Od7oSinjc36B9sQEMo_Ej_rgGDoKlND7GR5SZpoyJ8RboMS9G1fwa6nyIOQPRkiOLwwWQ-dzhndnEjcQZ_IPPYvoZcvReyKIk3h3Jf6MpTx-SUPvIUqfI4W9SGSJJcWZLNB3Q6MUYAwEffRFGYTBseCFwmePdzFeY2D6Y3q4TekDCnhClvwCuRKeY6KBQt5usneVuI-Tt9ASoLU5GuG_WXP14n28kf0ll1O76mMF_oVZ_gFtZ7B0xsnLamGbjT1ujrigZr2v60pvtzu96Bu7Nu1mfaRjhfttu95pi8fderc5nDVWG6oWrtGVrqvDWq8P2_1Wr_Zmi2dzMNWhbjeHulXbigZ0_uHHhWOeqFnXG73dLzy25LncNa2f_anznUtNRi3bqWO1rbxj4c864sSXi_gEq9_gt94J5dQfLfn-AC6_pZ0sBinywpNw93u5mJJvfjwonZN-alcmDkqfMv_9ZzmmmI2u9KkMla_Jfa5ro_8KAAD__x0H-kc">