Fix issue 9216: reset() method confusion (#2025)
* Fix issue 9216 with smart pointer reset * Check for arrow
This commit is contained in:
parent
60b670babd
commit
ab0fcc7640
|
@ -5090,7 +5090,7 @@ static void valueFlowSmartPointer(TokenList *tokenlist, ErrorLogger * errorLogge
|
||||||
values.push_back(v);
|
values.push_back(v);
|
||||||
valueFlowForwardAssign(tok, var, values, false, true, tokenlist, errorLogger, settings);
|
valueFlowForwardAssign(tok, var, values, false, true, tokenlist, errorLogger, settings);
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok, "%var% . reset (")) {
|
} else if (Token::Match(tok, "%var% . reset (") && tok->next()->originalName() != "->") {
|
||||||
if (Token::simpleMatch(tok->tokAt(3), "( )")) {
|
if (Token::simpleMatch(tok->tokAt(3), "( )")) {
|
||||||
std::list<ValueFlow::Value> values;
|
std::list<ValueFlow::Value> values;
|
||||||
ValueFlow::Value v(0);
|
ValueFlow::Value v(0);
|
||||||
|
@ -5106,7 +5106,7 @@ static void valueFlowSmartPointer(TokenList *tokenlist, ErrorLogger * errorLogge
|
||||||
const bool constValue = inTok->isNumber();
|
const bool constValue = inTok->isNumber();
|
||||||
valueFlowForwardAssign(inTok, var, values, constValue, false, tokenlist, errorLogger, settings);
|
valueFlowForwardAssign(inTok, var, values, constValue, false, tokenlist, errorLogger, settings);
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok, "%var% . release ( )")) {
|
} else if (Token::Match(tok, "%var% . release ( )") && tok->next()->originalName() != "->") {
|
||||||
std::list<ValueFlow::Value> values;
|
std::list<ValueFlow::Value> values;
|
||||||
ValueFlow::Value v(0);
|
ValueFlow::Value v(0);
|
||||||
v.setKnown();
|
v.setKnown();
|
||||||
|
|
|
@ -2339,6 +2339,17 @@ private:
|
||||||
" p.reset(new const A*[n]);\n"
|
" p.reset(new const A*[n]);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #9216
|
||||||
|
check("struct A {\n"
|
||||||
|
" void reset();\n"
|
||||||
|
" void f();\n"
|
||||||
|
"};\n"
|
||||||
|
"void g(std::unique_ptr<A> var) {\n"
|
||||||
|
" var->reset();\n"
|
||||||
|
" var->f();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void functioncall() { // #3443 - function calls
|
void functioncall() { // #3443 - function calls
|
||||||
|
|
Loading…
Reference in New Issue