Skip to content

Commit 9c31e0c

Browse files
Fix #10393 FP returnDanglingLifetime (#3562)
1 parent a0d3c2c commit 9c31e0c

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6538,6 +6538,11 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
65386538
setValueType(tok, valuetype);
65396539
}
65406540

6541+
else if (Token::simpleMatch(tok->previous(), "= {") && tok->tokAt(-2) && tok->tokAt(-2)->valueType()) {
6542+
ValueType vt = *tok->tokAt(-2)->valueType();
6543+
setValueType(tok, vt);
6544+
}
6545+
65416546
// library type/function
65426547
else if (tok->previous()) {
65436548
if (tok->astParent() && Token::Match(tok->astOperand1(), "%name%|::")) {

test/testautovariables.cpp

100755100644
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,13 @@ class TestAutoVariables : public TestFixture {
24742474
true);
24752475
ASSERT_EQUALS("", errout.str());
24762476

2477+
check("std::string f(std::string s) {\n"
2478+
" std::string r = { s.begin(), s.end() };\n"
2479+
" return r;\n"
2480+
"}\n",
2481+
true);
2482+
ASSERT_EQUALS("", errout.str());
2483+
24772484
check("struct A {\n"
24782485
" std::vector<std::unique_ptr<int>> mA;\n"
24792486
" void f(std::unique_ptr<int> a) {\n"

0 commit comments

Comments
 (0)