cppcheck
cppcheck copied to clipboard
Don't set pure for const functions [refs #12696]
FWIW here's a reduced example:
class QModelIndex;
struct ResultsTree {
void copy();
QStandardItemModel mModel;
QItemSelectionModel mSelectionModel{};
};
void ResultsTree::copy()
{
QString text;
for (QModelIndex index : mSelectionModel.selectedRows()) {
QStandardItem* item = mModel.itemFromIndex(index);
if (!item->parent()) {
text += item->text() + '\n';
continue;
}
}
}
Before this change, the valueflow was
Line 14
! always {!<=-1,!>=2}
item always symbolic=(mModel.itemFromIndex(index))
Line 15
item always symbolic=(mModel.itemFromIndex(index))
'\n' always 10
Those symbolic values disappear without pure, affecting isAliasOf() and ultimaltely isVariableChanged().