Fix issue 9329: FP knownConditionTrueFalse - vector modified by function calls (#2145)

This commit is contained in:
Paul Fultz II 2019-09-05 09:42:26 -05:00 committed by amai2012
parent e657cf4073
commit 9e140831eb
2 changed files with 29 additions and 0 deletions

View File

@ -5426,6 +5426,8 @@ static bool isContainerSizeChanged(nonneg int varId, const Token *start, const T
break;
};
}
if (isContainerSizeChangedByFunction(tok))
return true;
}
return false;
}

View File

@ -3218,6 +3218,33 @@ private:
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueContainer() {
// #9329
check("void c1(std::vector<double>&);\n"
"void c2(std::vector<double>&);\n"
"void foo(int flag) {\n"
" std::vector<double> g;\n"
" if (flag)\n"
" c1(g );\n"
" else\n"
" c2(g );\n"
" if ( !g.empty() )\n"
" return;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void foo(int flag) {\n"
" std::vector<double> g;\n"
" if (flag)\n"
" c1(g );\n"
" else\n"
" c2(g );\n"
" if ( !g.empty() )\n"
" return;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void multiConditionAlwaysTrue() {
check("void f() {\n"
" int val = 0;\n"