Fix 10589: False positive: danglingLifetime for moved unique ptr (#3547)

This commit is contained in:
Paul Fultz II 2021-11-06 13:08:19 -05:00 committed by GitHub
parent f5f600bafc
commit 6338c2396c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -2515,6 +2515,8 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
{
if (value.isUninitValue())
return false;
if (value.isLifetimeValue())
return false;
return true;
}

View File

@ -2465,6 +2465,15 @@ private:
"}\n",
true);
ASSERT_EQUALS("", errout.str());
check("struct A {\n"
" std::vector<std::unique_ptr<int>> mA;\n"
" void f(std::unique_ptr<int> a) {\n"
" auto x = a.get();\n"
" mA.push_back(std::move(a));\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void danglingLifetimeContainerView()