<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86471>86471</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Create check for "MEM56-CPP. Do not store an already-owned pointer value in an unrelated smart pointer"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy,
check-request
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PiotrZSL
</td>
</tr>
</table>
<pre>
Background: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM56-CPP.+Do+not+store+an+already-owned+pointer+value+in+an+unrelated+smart+pointer
```
A& getA();
void foo()
{
std::shared_ptr<A> a(&getA());
}
```
AC:
* should support unique_ptr & shared_ptr
* should flag any pointers being passed to smart pointer constructor or reset method
* should ignore when result of new operator, release method call is passed to smart_ptr
* should ignore smart_ptr with custom deleter
Proposed name: bugprone-smart-ptr-initialization, or something else like: suspicious, or something that would point out that object is stolen.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2vqzYQ_TVmMwoCE0KyYAHJy6pPulJ33VTGTMC9jodnj2-U_vrK3NzPVo2CEePj4-PjmVEhmMkhtqLuRX3KVOSZfPtkiP0fv_-WDTTe217p58lTdKOoOpiZlyCqTsizkOebeTZ5QJPra8xxjEKeNbmLjeg0CnkeTVisuqfwYmNIj5Dnnz9-1rvN8ekpF7I_kZC9IxayD0weheyVS4P1qMb7hm4ORyH7hYxj9EL2L8rGBDPuDRudR6t4xYWr8vwJX5xE0T3GXfH4r5_QCbmDCbkTci_kQVT9YwLghcwIF6LHzFtYNB-Q9Rc4uSKqLszK4_jnwl5Ux05UP0Cta3ef-L9uIZrT_4h7HbtjYn8NyA7CTNGOEOKykGeIzvyKmPaEdJJPEr6vuFg1gXJ3eLgSYEDjJlhUCDgCE6y2vU2DJhfYR83kgTx4DMhwRZ5p_Be3mRx5hNuMLgGjZaALOLwBLegVkxfyCB4tqoAPEtDKWjDhu4D_FP_Y4B0AN8Mz6BiYrjCixW_X_ORpocTq1BVTzg5xWjw53KwUm4X9xjjDRlnzt2JDLgkkD4GSuuQL2oBgzfO6PMSwGG0o5e43HM-K4baqXK0DivwapOEv1JyOGJgsujwb22o8VAeVYVs2ZVnVVVGW2dzu9R7LQsrLMFx0WTfFQe3VoKVqmn0zjIfMtLKQ26KSddHURVnm5bbYSlWp3RYvhUIttgVelbG5tS_XnPyUmRAitvvdtikzqwa0YS1xKbVVbtqwGe9CSiGPKTSjft54_BUxcIrWp8y3iWozxCmIbWFN4PBBzobt2jI-kdUnOHpUjLDSwYVSTsqPSocTgSOGtcZBOfhS3--Jt9Y2GJcQ71X9NTmFlFn0tv3aiSbDcxxyTVchz0nq47VZPKWbEPK8mpL6z-rLPwEAAP__oBCaMQ">