<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/145981>145981</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Check request: readability-unnecessary-unique-release
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
denzor200
</td>
</tr>
</table>
<pre>
`std::shared_ptr`'s constructor has a lot of overloads, one of them has `unique_ptr` parameter.
People don't know about existense of that overload.
I've seen the code like this all over the place:
```
std::shared_ptr<Foo> process(std::unique_ptr<Foo> foo) {
// ...
return std::shared_ptr<Foo>(foo.release());
}
```
Need a check that will find such patterns and will change it to use constructor's overload with `unique_ptr` parameter:
```
std::shared_ptr<Foo> process(std::unique_ptr<Foo> foo) {
// ...
return std::shared_ptr<Foo>(std::move(foo));
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMk82OmzAQx59muIyCjCEQDhzY3UbqpeobVMYegruOzdpDttunryBpuqqqPVeyxMd8-f-bGZWSPXmiDvYPsH_K1MJTiJ0h_zNEKUQ2BPPWQS0SGyh7KPs0qUjm28wRagGySaiDTxwXzSHipBIqdIExjBguFF1QJoF8xOBp_ccTnTcvqMXi7ctCt1Q4q6jOxBRzEP1XCrMjNMGDbBiffXhFNYSFkX7YxOTTLZvie5k17jPI5kKYiPxaCnUwhM4-E_JkEyrnNvfNNjulaRUl-lXK9Yj-X0rLx2MIUH7COQZNKYE83N3eqbi7jSGAbBGaBxA9IoI8gjxinufX70i8RI8flQJ5GEPIIzlSiUAeQLbrKdeU0Dz9dWsQ_Rcigwr1RPr5SubVOoej9QbToiecFTNFn1B5c7XpSfkToWXkgEui973cevubLb5anj7o2f-M8W4-hwtdsX7AMjNdadqyVRl1RbMXbVNXhyKbumpsqSqrUatKyKIh3Qijh2ZsTVnqwlBmOynkXtSyllIWsshVWbdamWoYxnrfCgWVoLOyLnfucs5DPGU2pYW6otq3hyJzaiCXtk2UUjvlTzu25g2kXDczdmvUblhOCSrhbOL0Jw9bdtsOvwvbP-HjNgqRXhZKDGWPkZRRg3WW33aL97Q2QcX1fYW_uw1btkTXTcxzWrltzE-Wp2XIdTiDPK5lb4_dHMN30gzyuGlJII83OZdO_goAAP__DCdfpw">