Fixed #8689 (False positive: containerOutOfBounds after function call)
This commit is contained in:
parent
f88326c51f
commit
cc402869a6
|
@ -3463,7 +3463,14 @@ static bool isContainerSizeChangedByFunction(const Token *tok)
|
|||
parent = parent->astParent();
|
||||
while (parent && parent->str() == ",")
|
||||
parent = parent->astParent();
|
||||
return parent && Token::Match(parent->previous(), "%name% (");
|
||||
if (!parent)
|
||||
return false;
|
||||
if (Token::Match(parent->previous(), "%name% ("))
|
||||
return true;
|
||||
// some unsimplified template function, assume it modifies the container.
|
||||
if (Token::simpleMatch(parent->previous(), ">") && parent->linkAt(-1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void valueFlowContainerReverse(const Token *tok, unsigned int containerId, const ValueFlow::Value &value, const Settings *settings)
|
||||
|
|
|
@ -3372,6 +3372,13 @@ private:
|
|||
"}";
|
||||
ASSERT(tokenValues(code, "x . front").empty());
|
||||
|
||||
code = "void f() {\n" // #8689
|
||||
" std::list<int> x;\n"
|
||||
" f<ns::a>(x);\n"
|
||||
" x.front();\n" // <- unknown container size
|
||||
"}";
|
||||
ASSERT(tokenValues(code, "x . front").empty());
|
||||
|
||||
code = "void f(std::vector<int> ints) {\n" // #8697
|
||||
" if (ints.empty())\n"
|
||||
" abort() << 123;\n"
|
||||
|
|
Loading…
Reference in New Issue