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

ValueFlow: pass ErrorLogger by reference into ValueFlow::setValues() / removed need for LifetimeStore::Context #5299

Merged
merged 9 commits into from
Apr 4, 2024

Conversation

firewave
Copy link
Collaborator

@firewave firewave commented Aug 7, 2023

No description provided.

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with that.

@firewave firewave marked this pull request as draft August 7, 2023 18:39
@firewave
Copy link
Collaborator Author

firewave commented Aug 7, 2023

Needs some reworking around givenACodeSampleToTokenize first.

@firewave firewave force-pushed the ptr-ref-v branch 4 times, most recently from e7bc1ff to ed3cb49 Compare March 9, 2024 16:42
@firewave firewave changed the title ValueFlow: pass ErrorLogger by reference into ValueFlow::setValues() ValueFlow: pass ErrorLogger by reference into ValueFlow::setValues() / removed need for LifetimeStore::Context Mar 9, 2024
@firewave firewave force-pushed the ptr-ref-v branch 4 times, most recently from d0d4904 to 38c8092 Compare March 9, 2024 23:15
: analyzer(analyzer), tokenList(tokenList), errorLogger(errorLogger), settings(settings)
{}
ValuePtr<Analyzer> analyzer;
const TokenList& tokenList;
ErrorLogger* const errorLogger;
ErrorLogger& errorLogger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the class not assignable. This should be a pointer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That ship has already sailed - some one line above.

I will take a look at adding that clang-tidy check about this (there was a case of false positives which I am not sure is fixed yet) and there's also #4785 and some discussions which related to that (which apparently are not linked).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI There also would be a compiler error if we would actually try to assign those types. I ran into this issue while working on it. So it is not a silent failure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I encountered the first issue we have with this in some other changes. I will try to figure out how to properly handle it so it can be easily be applied in the future. Nothing to do here though since this doesn't change anything as we were using references before.

mContext->errorLogger = errorLogger;
mContext->settings = &settings;
}
mutable Token* forwardTok{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about using the mutable keyword here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither - but removing the const from the function had quite a ripple effect before - will check again. I think this might be a sensible use of mutable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ripple effect wasn't as bad as I remember. The object was only const when passing it around so that was not fully enforced and is actually fine.

@firewave firewave force-pushed the ptr-ref-v branch 4 times, most recently from 111292c to 53dd484 Compare March 11, 2024 10:08
@@ -3408,11 +3408,12 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
const bool doValueFlow = !disableValueflowEnv || (std::strcmp(disableValueflowEnv, "1") != 0);

if (doValueFlow) {
assert(mErrorLogger);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the change in ImportProject this can no longer happen. I did not change it to a reference yet since it used in a lot of redundant test code. As I plan to clean up that redundancy I will address it with that upcoming change instead of touching the code twice.

@@ -3440,6 +3441,7 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
return true;
}

// cppcheck-suppress unusedFunction - used in tests only
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was surprising but it actually foreshadows the cleanup I am planning to make.

@firewave firewave requested a review from danmar March 11, 2024 10:19
@firewave firewave force-pushed the ptr-ref-v branch 2 times, most recently from 8eac401 to 39369b4 Compare March 11, 2024 15:02
@firewave firewave marked this pull request as ready for review March 12, 2024 00:15
@firewave firewave merged commit 228f9cd into danmar:main Apr 4, 2024
64 checks passed
@firewave firewave deleted the ptr-ref-v branch April 4, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants