Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12998 FP knownConditionTrueFalse with QString::split() #6675

Merged
merged 5 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7125,7 +7125,10 @@ static void valueFlowContainerSize(const TokenList& tokenlist,
for (const ValueFlow::Value& value : values)
setTokenValue(tok, value, settings);
} else if (Token::Match(tok, "%name%|;|{|}|> %var% =") && Token::Match(tok->tokAt(2)->astOperand2(), "[({]") &&
(tok->tokAt(3) == tok->tokAt(2)->astOperand2() || settings.library.detectContainer(tok->tokAt(3)))) {
// init list
((tok->tokAt(2) == tok->tokAt(2)->astOperand2()->astParent() && !tok->tokAt(2)->astOperand2()->astOperand2() && tok->tokAt(2)->astOperand2()->str() == "{") ||
// constructor
(!Token::simpleMatch(tok->tokAt(2)->astOperand2()->astOperand1(), ".") && settings.library.detectContainer(tok->tokAt(3))))) {
Token* containerTok = tok->next();
if (containerTok->exprId() == 0)
continue;
Expand Down
6 changes: 6 additions & 0 deletions test/cfg/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ bool QString7(QString s, const QString& l) {
return l.startsWith(s);
}

void QString_split(const char* name) { // #12998
// cppcheck-suppress valueFlowBailoutIncompleteVar // FIXME
QStringList qsl = QString(name).split(';', Qt::SkipEmptyParts);
if (qsl.isEmpty()) {}
}

namespace NTestStd // #12355
{
using namespace std;
Expand Down
Loading