Don't set pure for const functions [refs #12696]#6383
Draft
chrchr-github wants to merge 2 commits into
Draft
Conversation
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 Those symbolic values disappear without |
danmar
reviewed
May 20, 2024
| func.ispure = true; | ||
| else if (functionnodename == "const") { | ||
| func.ispure = true; | ||
| func.isconst = true; // a constant function is pure |
Collaborator
There was a problem hiding this comment.
as I understand a const function is always pure. does valueflow assume that the function reads from global memory if it's pure?
Collaborator
Author
There was a problem hiding this comment.
I'm not sure how ValueFlow uses these attributes.
We also need to figure out what const is supposed to mean in the library, see #6385
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.