Fix #10393 FP returnDanglingLifetime (#3562)

This commit is contained in:
chrchr-github 2021-11-15 20:36:38 +01:00 committed by GitHub
parent a0d3c2c719
commit 9c31e0ce54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -6538,6 +6538,11 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
setValueType(tok, valuetype);
}
else if (Token::simpleMatch(tok->previous(), "= {") && tok->tokAt(-2) && tok->tokAt(-2)->valueType()) {
ValueType vt = *tok->tokAt(-2)->valueType();
setValueType(tok, vt);
}
// library type/function
else if (tok->previous()) {
if (tok->astParent() && Token::Match(tok->astOperand1(), "%name%|::")) {

7
test/testautovariables.cpp Executable file → Normal file
View File

@ -2474,6 +2474,13 @@ private:
true);
ASSERT_EQUALS("", errout.str());
check("std::string f(std::string s) {\n"
" std::string r = { s.begin(), s.end() };\n"
" return r;\n"
"}\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"