[libcxx-commits] [libcxx] [libc++] run clang-tidy on src/ in the CI (PR #121198)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 25 04:58:37 PST 2025


https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/121198

>From 8dafe63eba17b2b654dcc7c6621e355c4daa43e0 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Fri, 27 Dec 2024 11:05:25 +0100
Subject: [PATCH] [libc++] run clang-tidy on src/ in the CI

---
 libcxx/src/.clang-tidy                  | 16 +++++++++++++++-
 libcxx/test/configs/cmake-bridge.cfg.in |  1 +
 libcxx/test/libcxx/clang_tidy.sh.py     |  2 ++
 libcxx/utils/ci/run-buildbot            |  1 +
 4 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 libcxx/test/libcxx/clang_tidy.sh.py

diff --git a/libcxx/src/.clang-tidy b/libcxx/src/.clang-tidy
index ec8f2e0a76a3c..3d5493d965558 100644
--- a/libcxx/src/.clang-tidy
+++ b/libcxx/src/.clang-tidy
@@ -1,4 +1,18 @@
 InheritParentConfig: true
 
 Checks: >
-  -readability-identifier-naming
+  -clang-analyzer-*,
+
+  -llvm-include-order,
+
+  -modernize-loop-convert,
+  -modernize-use-equals-delete,
+  -modernize-use-nullptr,
+  -modernize-use-override,
+
+  -readability-identifier-naming,
+  -readability-function-cognitive-complexity,
+  -readability-function-size,
+  -readability-simplify-boolean-expr,
+
+# TODO: Consider enabling clang-analyzer. Without the checks clang-tidy runs 18x faster on my system.
diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in
index 61f821a7e4f6b..d7d588669032d 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/cmake-bridge.cfg.in
@@ -23,6 +23,7 @@ config.recursiveExpansionLimit = 10
 config.test_exec_root = os.path.join('@LIBCXX_BINARY_DIR@', 'test')
 
 # Add substitutions for bootstrapping the test suite configuration
+config.substitutions.append(('%{bin-dir}', '@LIBCXX_BINARY_DIR@'))
 config.substitutions.append(('%{libcxx-dir}', '@LIBCXX_SOURCE_DIR@'))
 config.substitutions.append(('%{install-prefix}', '@LIBCXX_TESTING_INSTALL_PREFIX@'))
 config.substitutions.append(('%{include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_DIR@'))
diff --git a/libcxx/test/libcxx/clang_tidy.sh.py b/libcxx/test/libcxx/clang_tidy.sh.py
new file mode 100644
index 0000000000000..91ae9cf46ba4c
--- /dev/null
+++ b/libcxx/test/libcxx/clang_tidy.sh.py
@@ -0,0 +1,2 @@
+
+# RUN: %{python} %{libcxx-dir}/../clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -clang-tidy-binary %{clang-tidy} -warnings-as-errors \* -source-filter=".*libcxx/src.*" -quiet -p %{bin-dir}/..
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index f1ede6474eb9e..2afb5a5517efe 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -144,6 +144,7 @@ function generate-cmake() {
     generate-cmake-base \
           -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
           -DLIBCXX_CXX_ABI=libcxxabi \
+          -DCMAKE_EXPORT_COMPILE_COMMANDS=On \
           "${@}"
 }
 



More information about the libcxx-commits mailing list