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

Clang-tidy CI test: bump version from 16 to 17 #5600

Open
wants to merge 36 commits into
base: development
Choose a base branch
from

Conversation

lucafedeli88
Copy link
Member

@lucafedeli88 lucafedeli88 commented Jan 24, 2025

This PR bumps the version used for clang-tidy CI tests from 16 to 17. It also addresses all the issues found with the upgraded tool.

To be merged after #5592

The issues found 🧐 and fixed 🛠️ with the upgraded tool are the following :

  • bugprone-switch-missing-default-case
    A newly introduced check to flag switch statements without a default case (unless the argument is an enum)

  • cppcoreguidelines-rvalue-reference-param-not-moved
    A newly introduced check to flag when an rvalue reference argument of a function is never moved inside the function body.
    ⚠️ Warning: in order to have this check compatible with performance-move-const-arg I had to set performance-move-const-arg.CheckTriviallyCopyableMove to false (specifically for the three methods in ablastr::utils::msg_logger accepting std::vector<char>::const_iterator&& rit arguments).

  • misc-header-include-cycle
    A newly introduced check to prevent cyclic header inclusions.

  • modernize-type-traits
    A newly introduced check. The idea is to replace currencies of, e.g., std::is_integral<T>::value, with the less verbose alternative std::is_integral_v<T>

  • performance-avoid-endl
    A newly introduced check. The idea is to replace << std::endl with \n, since endl also forces a flush of the stream. In few cases flushing the buffer is actually the desired behavior. Typically, this happens when we want to write to std::cerr, which is however automatically flushed after each write operation. In cases where actually flushing to std::cout is the desired behavior one can do << \n << std::flush , which is arguably more transparent than << std::endl.

  • performance-noexcept-swap
    For performance reasons it is better if swap functions are declared as noexcept, in order to allow the compiler to perform more aggressive optimizations. In any case, we can use the AMReX function amrex::Swap, which is noexcept.

🔄 Re-enabled checks:

  • readability-misleading-indentation
    This check was already available in v16, but a bug led to false positives. The bug has been corrected in v17 of the tool, so we can re-enable the check.

⛔ The PR excludes the following checks :

  • cppcoreguidelines-missing-std-forward
    A newly introduced check that warns when a forwarding reference parameter is not forwarded. In order to comply with this check I think that I have to pass some parameters by reference to lambda functions inside ParallelFor constructs. However, this leads to issues when we compile for GPUs. Therefore, I think that the best solution is to exclude this check. See an example below (for PredFunc&& filter ):
amrex::ParallelForRNG(np,
    [=,&filter] AMREX_GPU_DEVICE (int i, amrex::RandomEngine const& engine)
    {
        p_mask[i] = filter(src_data, i, engine);
    });
  • misc-include-cleaner
    It would be awesome to include this check. However, as it is now implemented, it has no notion of "associated headers". For instance, let's suppose that the header MyClass.H has #include<string> and that MyClass.cpp has #include "MyClass.H" and uses std:string somewhere. In this case, the check raises a warning stating that you should include <string> in MyClass.cpp even if it is transitively included via the associate header MyClass.H . For this reason, for the moment, it is better to periodically check headers with the IWYU tool.

@lucafedeli88 lucafedeli88 added component: tests Tests and CI cleaning Clean code, improve readability labels Jan 24, 2025
@ax3l
Copy link
Member

ax3l commented Jan 29, 2025

Ready for rebase, v16 PR is in :)

@lucafedeli88 lucafedeli88 changed the title [WIP] Clang-tidy CI test: bump version from 16 to 17 Clang-tidy CI test: bump version from 16 to 17 Feb 3, 2025
@lucafedeli88 lucafedeli88 requested review from ax3l and EZoni February 3, 2025 14:26
@ax3l ax3l self-assigned this Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleaning Clean code, improve readability component: tests Tests and CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants