Skip to content

Commit

Permalink
Support non-STL containers
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Dec 1, 2023
1 parent fedac97 commit a6dc812
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3260,7 +3260,7 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings
} else if (ftok->variable() && ftok == ftok->variable()->nameToken()) { // variable init/constructor call
if (ftok->variable()->type() && ftok->variable()->type()->needInitialization == Type::NeedInitialization::True)
return ExprUsage::Used;
if (ftok->variable()->isStlType()) // STL types don't initialize external variables
if (ftok->variable()->isStlType() || (ftok->variable()->valueType() && ftok->variable()->valueType()->container)) // STL types or containers don't initialize external variables
return ExprUsage::Used;
} else {
const bool isnullbad = settings->library.isnullargbad(ftok, argnr + 1);
Expand Down
7 changes: 7 additions & 0 deletions test/cfg/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ void duplicateExpression_QString_Compare(QString style) //#8723
{}
}

void QVector_uninit()
{
int i;
// cppcheck-suppress [uninitvar, unreadVariable]
QVector<int> v(i);
}

void QStack1(QStack<int> intStackArg)
{
for (int i = 0; i <= intStackArg.size(); ++i) {
Expand Down

0 comments on commit a6dc812

Please sign in to comment.