Skip to content

Migrate to use clang-tidy v22#742

Open
yungyuc wants to merge 2 commits intosolvcon:masterfrom
yungyuc:refactor/clang-tidy-22
Open

Migrate to use clang-tidy v22#742
yungyuc wants to merge 2 commits intosolvcon:masterfrom
yungyuc:refactor/clang-tidy-22

Conversation

@yungyuc
Copy link
Copy Markdown
Member

@yungyuc yungyuc commented Apr 29, 2026

Reconfigure GitHub Actions to use clang-tidy v22.

  • Add --allow-no-checks command-line argument for clang-tidy to turn off the error message "Error: no checks enabled."
  • Turns off overly aggressive checks in .clang-tidy configuration file.
  • Add inline NOLINT comments to turn off overly aggressive checks locally.

In addition, use -std=c++23 instead of c++2b.

The migration work is tedious review and update. Not a lot to talk about.

yungyuc added 2 commits April 29, 2026 19:09
* Add `--allow-no-checks` command-line argument for clang-tidy to turn off the
  error message "Error: no checks enabled."
* Turns off overly aggressive checks in `.clang-tidy` configuration file.
* Add inline `NOLINT` comments to turn off overly aggressive checks locally.
sudo apt-get -qqy update
sudo apt-get -qy install clang-tidy-21
sudo ln -fs "$(which clang-tidy-21)" "/usr/local/bin/clang-tidy"
sudo apt-get -qy install clang-tidy-22
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Upgrade to clang-tidy 22 for Linux.

# qt6 versioning independently from the OS.
# brew install llvm@21 qt6
brew install llvm@21
brew install llvm@22
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Upgrade to clang-tidy 22 for macos.

${COMMON_COMPILER_OPTIONS}
-Wno-unused-value # for PYBIND11_EXPAND_SIDE_EFFECTS in pybind11.h
-Wno-noexcept-type # GCC
-Wno-elaborated-enum-base # for apple accelerate/veclib
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is to piggyback for another enhancement I am doing. -Welaborated-enum-base will be noisy.

Comment thread .clang-tidy
Checks: >
*,-clang-analyzer-alpha.*,-hicpp-*,
*,
-clang-analyzer-*,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Make it multiple lines and skip all of clang-analyzer-*.

Comment thread CMakeLists.txt
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}"
"-header-filter=/cpp/.\*"
"--extra-arg=-std=c++23"
# FIXME: Remove --allow-no-checks in the future after figuring out
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is strange to have the Error: no checks enabled. with the clang-tidy v22 upgrade. I have to add --allow-no-checks to have tidy run through. We should revisit this in the future.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since we are using --allow-no-checks, it might be useful to add a CI step to print the enabled checks for visibility

@yungyuc yungyuc self-assigned this Apr 29, 2026
@yungyuc yungyuc added the build Build system and automation label Apr 29, 2026
@yungyuc yungyuc marked this pull request as ready for review April 29, 2026 11:38
Copy link
Copy Markdown
Collaborator

@KHLee529 KHLee529 left a comment

Choose a reason for hiding this comment

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

LGTM but I have some questions left in comments.

const ssize_t m = static_cast<ssize_t>(l.shape(0));
const ssize_t n = static_cast<ssize_t>(b.shape(1));
small_vector<size_t> y_shape{static_cast<size_t>(m), static_cast<size_t>(n)};
const auto m = static_cast<ssize_t>(l.shape(0));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it considered better to use type inference instead of explicit type declaration ? What's the reason?

Copy link
Copy Markdown
Member Author

@yungyuc yungyuc Apr 29, 2026

Choose a reason for hiding this comment

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

Yes and no. It is suggested by modernize-use-auto. This line should use auto because it is casting.

Except the scenarios listed in modernize-use-auto and few others, we should spell out type names and avoid auto. Type names are good for readability.

{

enum SimdFeature
enum SimdFeature : std::uint8_t
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't this need explicitly declared as enum class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

@ExplorerRay ExplorerRay left a comment

Choose a reason for hiding this comment

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

The change in CI part looks good to me.

Copy link
Copy Markdown
Collaborator

@chestercheng chestercheng left a comment

Choose a reason for hiding this comment

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

Overall LGTM.
I also noticed Node 20 deprecation warnings in CI, so I opened #743 to track it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build system and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants