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

Add all the performance-* clang-tidy checks #1532

Merged

Conversation

@lucafedeli88 lucafedeli88 changed the title [WIP] Add all the performance-* clang-tidy checks Add all the performance-* clang-tidy checks Oct 4, 2023
@lucafedeli88
Copy link
Contributor Author

I see that a test case is failing. I will investigate

@lucafedeli88
Copy link
Contributor Author

I see that a test case is failing. I will investigate

The bug should be fixed!

@franzpoeschel
Copy link
Contributor

Currently looking through this. The checks are very useful, thank you for adding this!

It seems that in some places the suggested fixes by clang-tidy started an avalanche of recursive fixes and I'm trying to undo those. (Basic pattern: A std::move() was forgotten or wrongly applied, so clang-tidy suggests to use a const & argument and that change then propagates through the entire code base)

Feel free to ping either Axel or me when you need to have the CI started

@franzpoeschel
Copy link
Contributor

franzpoeschel commented Oct 20, 2023

I've taken the freedom to push a commit on this branch that reverts some of the changes and tries to fix the warnings in another way. Most of these were "pass by value" turned into "pass by reference" because of:

  • std::move was forgotten or wrongly applied. Fix that instead of changing the function signatures.
  • API consistency: Some parameters are needed only in some configurations. clang-tidy then thinks that an unused parameter should be turned to a reference. Depending on the #ifdef logic, several implementations may be chosen. Here, we should optimize for the implementations that actually use the parameters since the others are often just there to satisfy the linker.
  • Planned changes: A parameter is not yet used today, but will be in future. clang-tidy again thinks that unused parameters should be references.

The one thing that is a bit dangerous about clang-tidy imo is that it is very eager to change the API and ABI because of an implementation detail. This is mostly fine since those cases can mostly be handled case-by-case, but one should be aware of it.

One method that seems to successfully trick clang-tidy is to define something like template<typename T> void forget(T){} and passing unused parameters off into that template. I'll need to add a second commit that puts this in its own header, but not today.

Let's first see what the CI now thinks of this.

EDIT: I seem to have broken some things. Will investigate next week.

@franzpoeschel franzpoeschel force-pushed the clang_tidy_all_performance_checks branch from 7f23f9b to d216aad Compare October 23, 2023 08:36
@franzpoeschel franzpoeschel force-pushed the clang_tidy_all_performance_checks branch from 1b05c0a to 6aba6b8 Compare November 9, 2023 16:22
@franzpoeschel
Copy link
Contributor

franzpoeschel commented Nov 10, 2023

Hey @lucafedeli88
The CI is now passing. If you are fine with the changes I did (only in the code, I did not touch the checks), then I would merge this.

EDIT: I forgot one thing, CI needs to run again

@franzpoeschel franzpoeschel merged commit 71aa0e9 into openPMD:dev Nov 20, 2023
28 checks passed
@franzpoeschel
Copy link
Contributor

Merging this now, thank you for adding this!
Since many files are affected, this is likely to cause merge conflicts. But since each single change is mostly rather simple, the single merge conflicts should not be hard to resolve. In doubt, current changes can be replaced by incoming changes, and then clang-tidy suggestions can be reapplied.

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