<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/90174>90174</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] bugprone-use-after-move - false-negative
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy,
false-negative
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PiotrZSL
</td>
</tr>
</table>
<pre>
Example:
```
#include <memory>
struct A {};
struct ClassA
{
ClassA(std::unique_ptr<A>);
};
class ClassB
{
ClassB(std::unique_ptr<A> aaa)
: aa(std::move(aaa))
{
a = std::make_unique<ClassA>(std::move(aaa));
}
std::unique_ptr<A> aa;
std::unique_ptr<ClassA> a;
};
```
No issue from bugprone-use-after-move or from clang-analyzer-cplusplus.Move.
```
Example 2:
#include <iostream>
#include <memory>
struct Verbose
{
Verbose() { std::clog << __PRETTY_FUNCTION__ << '\n'; }
~Verbose() { std::clog << __PRETTY_FUNCTION__ << '\n'; }
Verbose(const Verbose&) { std::clog << __PRETTY_FUNCTION__ << '\n'; }
Verbose(Verbose&&) { std::clog << __PRETTY_FUNCTION__ << '\n'; }
Verbose& operator=(const Verbose&) { std::clog << __PRETTY_FUNCTION__ << '\n'; return *this; }
Verbose& operator=(Verbose&&) { std::clog << __PRETTY_FUNCTION__ << '\n'; return *this; }
};
struct Test
{
Test(std::unique_ptr<int> arg)
: a(std::move(arg))
{
consume_again(std::move(arg));
}
void consume_again(std::unique_ptr<int>) {}
std::unique_ptr<int> a;
};
int main() {
std::unique_ptr<int> a = std::make_unique<int>(1);
Test t1(std::move(a));
Test t2(std::move(a));
}
```
Detected by clang-analyzer-cplusplus.Move, but not by bugprone-use-after-move
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vk-PuzYQ_TTmYhGRMYHNgUNCNlKldvtTu63UXiIDA3FrcGqbVdNDP3tlIEs2JSiXRAkIPPPe_MuzuTGiahATstqS1c7jrT0qnXwTyurff_7ey1RxTl7_5vVJImEbEuxIcLlGwfDtH4GJJpdtgZSwtMZa6TNhr9cexuo2t3RDSbwl8Y6w7cRqKrkxF4p4sLi8hRdjCxcH27SN-KvFw8lqwtKNY4L1iPg_9NwB9DDbSfDtLDjlnDuC3mH4ELah7vXoV6sPJPAyGF_bj2ycErajowv_Ew89H2HpkKfLZgb1kloPvBseZqP_4jNt-clN-Uwhb9r-pqgwpkVaalXTrK1OWjXotwZ9XlrUvgueKt2v55I3lc8bLs__oPbzk2yN-y1-UB-4mKEZRpDCOIRf5k0oYzXyepy4h8fxV9SZMng7FJR-rsALgbXr4Fi4XKrKAROW0sPh20-v7--_Hfa_vKXv3_34djhclgjEZJU27sa2V62ilP77VPQRPFeNGZOE6Klk1zRPZYqoOqHmVmnCdk_LUqNtdUMJbOxRmMejeUIZZkK5908d5vsdjZ0Y7u71PckTje10QFc3otdJ3pQ29ZbTiuea09Z44BUXzazztLBRSj-UKO7jTMQ-VP0LyHyuM5onGkvrnvOC-yDonNZfAn1Z3qbuekPtcqpUE4XqreEB63Fkbvbu7rpDi7nFgmbneaEmkNKstbRR1tneEX2vSFixZmvuYbKMl-FyuQoZ845JGEZlsIIMowjYqgxXJYMwLrMohzUWWeCJBAIIgxCiIF4GjC3iiOcQQh5BsOa8KEkYYM2FXEj5US-UrrxuD0rWwTIOPckzlKY70QD0iVhRnAkAgZQAlFwa9BusuBUuGXAHH504LD9rK0PCQApjzYhuhZXdEekKbbW7u9tRn37l8Fotk6O1J-PaA3sC-0rYY5stclUT2Dui4eaftPoDc0tg3-VkCOy7tP4LAAD__4qrtR4">