From 9c1733260107eafddac6cb333e6f18d246efb3b4 Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones Date: Mon, 24 Aug 2026 18:25:34 -0400 Subject: [PATCH] devcontainer: Add `clang-tidy`, `clang-tools`, and `clazy` Provide the analysis tools our CI images carry: `clang-tidy` to run the checks in `.clang-tidy`, `clang-tools` for `scan-build`, and `clazy`, the compiler our Clazy job builds with. Name the version of `clang-tidy` our checks are written against rather than install Ubuntu's unversioned package, which is a release behind and reports `cmake-use-cmsys-fstream` where it should not. `CMakeLists.txt` searches for `clang-tidy` only under the unversioned name, so link the version installed by name to it, as we already do for `clang-format`. `clazy` and `clang-tools` remain whatever versions Ubuntu carries rather than the ones the CI image does, so expect their diagnostics to differ from those jobs'. CMake's own clang-tidy checks are not available either way: `CMake_USE_CLANG_TIDY_MODULE` needs `Utilities/ClangTidyModule` built against Clang's development files, which are not installed here. Suggested-by: Tyler Yankee --- .devcontainer/dev_packages.lst | 15 +++++++++++++++ .devcontainer/install_deps.sh | 5 ++++- Help/dev/devcontainer.rst | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.devcontainer/dev_packages.lst b/.devcontainer/dev_packages.lst index 1e4c62cb29..9d74a1dfba 100644 --- a/.devcontainer/dev_packages.lst +++ b/.devcontainer/dev_packages.lst @@ -36,6 +36,21 @@ ninja-build gdb valgrind +# Analyze CMake. `clazy` is the compiler our Clazy CI job builds with, +# `clang-tools` provides `scan-build`, and `clang-tidy` runs the checks in +# `.clang-tidy`. Name the version of `clang-tidy` our checks are written +# against: `Utilities/ClangTidyModule` tracks the Clang release our CI image +# carries, and older versions report `cmake-use-cmsys-fstream` where they +# should not. Ubuntu's unversioned `clang-tidy` package is a release behind. +# `clazy` and `clang-tools` are whatever versions Ubuntu carries, so expect +# their diagnostics to differ from those jobs'. CMake's own checks are not +# among them either way: `CMake_USE_CLANG_TIDY_MODULE` needs +# `Utilities/ClangTidyModule` built against Clang's development files, which +# are not installed here. +clang-tidy-22 +clang-tools +clazy + # Build the documentation. python3-sphinx diff --git a/.devcontainer/install_deps.sh b/.devcontainer/install_deps.sh index 3b80f4ff77..1a6f19b5a2 100755 --- a/.devcontainer/install_deps.sh +++ b/.devcontainer/install_deps.sh @@ -23,5 +23,8 @@ dpkg-reconfigure --frontend=noninteractive locales # `Utilities/Scripts/clang-format.bash` finds `clang-format-18` by name, but # make the unversioned name resolve to version 18 as well so that tools -# looking for it get the version our style rules require. +# looking for it get the version our style rules require. `CMakeLists.txt` +# searches for `clang-tidy` only under the unversioned name, so the version +# installed by name needs one too. ln -s "$(command -v clang-format-18)" /usr/local/bin/clang-format +ln -s "$(command -v clang-tidy-22)" /usr/local/bin/clang-tidy diff --git a/Help/dev/devcontainer.rst b/Help/dev/devcontainer.rst index ff0b63572b..ef88bfe2af 100644 --- a/Help/dev/devcontainer.rst +++ b/Help/dev/devcontainer.rst @@ -159,6 +159,22 @@ against, the container provides: $ cmake --build build-asan $ ctest --test-dir build-asan +* ``clang-tidy``, ``scan-build``, and ``clazy``, the compiler our Clazy CI + job builds with, to analyze CMake rather than only compile it: + + .. code-block:: console + + $ cmake -G Ninja -B build-tidy -S . -DCMake_RUN_CLANG_TIDY=ON + $ cmake -G Ninja -B build-clazy -S . -DCMAKE_CXX_COMPILER=clazy + + ``clang-tidy`` is the version our checks are written against, which is + not the one Ubuntu's unversioned package provides. ``scan-build`` and + ``clazy`` are whatever versions Ubuntu carries rather than the ones our + CI image does, so expect their diagnostics to differ from those jobs'. + CMake's own checks are not available either way: + ``CMake_USE_CLANG_TIDY_MODULE`` needs `Utilities/ClangTidyModule`_ built + against Clang's development files, which the container does not install. + * ``glab``, the `GitLab CLI`_, to work with merge requests, issues, and pipelines on our GitLab instance, and `glab-axi`_, a wrapper around it whose output follows the `AXI`_ conventions: @@ -173,6 +189,7 @@ against, the container provides: .. _`Kitware APT repository`: https://apt.kitware.com .. _`C++ Code Style`: source.rst#c-code-style .. _`.pre-commit-config.yaml`: ../../.pre-commit-config.yaml +.. _`Utilities/ClangTidyModule`: ../../Utilities/ClangTidyModule .. _`CMake Documentation Guide`: documentation.rst .. _`CMake Debugging Guide`: debug.rst .. _`GitLab CLI`: https://docs.gitlab.com/editor_extensions/gitlab_cli/