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

Don't set pure for const functions [refs #12696] #6383

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chrchr-github
Copy link
Collaborator

No description provided.

@chrchr-github chrchr-github changed the title Don't set pure for const functions Don't set pure for const functions [refs #12696] May 4, 2024
@chrchr-github chrchr-github marked this pull request as ready for review May 4, 2024 18:26
@chrchr-github
Copy link
Collaborator Author

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant