Fix 11358: FP containerOutOfBounds for container passed by pointer (#4626)
This commit is contained in:
parent
40a69e5afb
commit
3f88744851
|
@ -7689,6 +7689,14 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getIndirect(const Token* tok) const override
|
||||||
|
{
|
||||||
|
if (tok->valueType()) {
|
||||||
|
return tok->valueType()->pointer;
|
||||||
|
}
|
||||||
|
return ValueFlowAnalyzer::getIndirect(tok);
|
||||||
|
}
|
||||||
|
|
||||||
Action isModified(const Token* tok) const override {
|
Action isModified(const Token* tok) const override {
|
||||||
Action read = Action::Read;
|
Action read = Action::Read;
|
||||||
// An iterator won't change the container size
|
// An iterator won't change the container size
|
||||||
|
|
|
@ -886,6 +886,13 @@ private:
|
||||||
" v[0];\n"
|
" v[0];\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkNormal("void f(std::vector<int>* v) {\n"
|
||||||
|
" if (v->empty())\n"
|
||||||
|
" v->push_back(1);\n"
|
||||||
|
" auto x = v->back();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void outOfBoundsSymbolic()
|
void outOfBoundsSymbolic()
|
||||||
|
|
Loading…
Reference in New Issue