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

CheckInternal::checkRedundantNextPrevious(): Fix FN, simplify #6478

Merged
merged 8 commits into from
Jun 3, 2024

Conversation

chrchr-github
Copy link
Collaborator

@chrchr-github chrchr-github commented Jun 1, 2024

No description provided.

@firewave
Copy link
Collaborator

firewave commented Jun 1, 2024

The merge is bad - it removes unrelated stuff.

@firewave
Copy link
Collaborator

firewave commented Jun 1, 2024

It still changed unrelated code - see TemplateSimplifier::getTemplateInstantiations().

@chrchr-github chrchr-github marked this pull request as ready for review June 2, 2024 09:11
@@ -6749,7 +6749,7 @@ void Tokenizer::simplifyFunctionParameters()
// First step: Get list of argument names in parentheses
std::map<std::string, Token *> argumentNames;
bool bailOut = false;
Token * tokparam = nullptr;
const Token * tokparam = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems strange we can detect this now. Looks like some underlying false negative.

@firewave
Copy link
Collaborator

firewave commented Jun 3, 2024

Looks clean now.

@firewave
Copy link
Collaborator

firewave commented Jun 3, 2024

callgrind in CI: 63,252,683,153 -> 63,298,113,389

@chrchr-github
Copy link
Collaborator Author

That's with edf0104 already applied, right?

@firewave
Copy link
Collaborator

firewave commented Jun 3, 2024

callgrind in CI: 63,252,683,153 -> 63,298,113,389

I think this is fine.

But I wonder if there is a potential matchcompiler pass here.
If we dereference the result of any of these calls we could compile this to the corresponding previous() and next() calls.

@firewave
Copy link
Collaborator

firewave commented Jun 3, 2024

That's with edf0104 already applied, right?

Yes.

@firewave
Copy link
Collaborator

firewave commented Jun 3, 2024

Just a side note:

Calling it "redundant" is a bit misleading as using the Token::*At() functions actually changes the behavior as it prevents the potential dereference of a NULL pointer in a call chain. The additional checks obviously also affect the performance.

@firewave
Copy link
Collaborator

firewave commented Jun 3, 2024

But I wonder if there is a potential matchcompiler pass here.
If we dereference the result of any of these calls we could compile this to the corresponding previous() and next() calls.

With such a pass we could get rid of some of the manual optimizations we did by storing the result of an *At() call as only the calls which check the result need to be safe. That might slow down debug builds a bit though.

I will file a ticket about this.

@chrchr-github chrchr-github merged commit 32fefc6 into danmar:main Jun 3, 2024
63 checks passed
@chrchr-github chrchr-github deleted the chr_internal branch June 3, 2024 09:17
@firewave
Copy link
Collaborator

firewave commented Jun 3, 2024

I will file a ticket about this.

https://trac.cppcheck.net/ticket/12805

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.

2 participants