openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
138 stars 51 forks source link

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

Closed lucafedeli88 closed 10 months ago

lucafedeli88 commented 1 year ago

This PR adds all the performance-* checks to clang-tidy CI test, namely:

lucafedeli88 commented 12 months ago

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

lucafedeli88 commented 12 months ago

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

The bug should be fixed!

franzpoeschel commented 11 months ago

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 commented 11 months ago

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:

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 commented 10 months ago

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 commented 10 months ago

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.