Skip to content

Commit

Permalink
Fix #12998 FP knownConditionTrueFalse with QString::split() (#6675)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Aug 10, 2024
1 parent 9665347 commit cab3051
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7157,7 +7157,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

0 comments on commit cab3051

Please sign in to comment.