diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -130,6 +130,8 @@ message(STATUS "Using libc++ testing configuration: ${LIBCXX_TEST_CONFIG}") set(LIBCXX_TEST_PARAMS "" CACHE STRING "A list of parameters to run the Lit test suite with.") +set(LIBCXX_TEST_CLANG_TIDY "" CACHE STRING + "The optional clang-tidy version to use in the test suite.") # Benchmark options ----------------------------------------------------------- option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in --- a/libcxx/test/configs/cmake-bridge.cfg.in +++ b/libcxx/test/configs/cmake-bridge.cfg.in @@ -30,3 +30,4 @@ config.substitutions.append(('%{target-include}', '@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@')) config.substitutions.append(('%{lib}', '@LIBCXX_LIBRARY_DIR@')) config.substitutions.append(('%{executor}', '@LIBCXX_EXECUTOR@')) +config.substitutions.append(('%{clang-tidy}', shlex.quote('@LIBCXX_TEST_CLANG_TIDY@'))) diff --git a/libcxx/test/libcxx/clang_tidy.sh.cpp b/libcxx/test/libcxx/clang_tidy.sh.cpp --- a/libcxx/test/libcxx/clang_tidy.sh.cpp +++ b/libcxx/test/libcxx/clang_tidy.sh.cpp @@ -12,7 +12,7 @@ // UNSUPPORTED: gcc // TODO: run clang-tidy with modules enabled once they are supported -// RUN: clang-tidy %s --warnings-as-errors=* -header-filter=.* --config-file=%S/../../.clang-tidy -- -Wweak-vtables %{compile_flags} -fno-modules +// RUN: %{clang-tidy} %s --warnings-as-errors=* -header-filter=.* --config-file=%S/../../.clang-tidy -- -Wweak-vtables %{compile_flags} -fno-modules // Prevent from generating deprecated warnings for this test. #if defined(__DEPRECATED) diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -90,6 +90,8 @@ env: CC: "gcc-${GCC_STABLE_VERSION}" CXX: "g++-${GCC_STABLE_VERSION}" + # Some of GCC's warning flags are not supported by clang-tidy. + # Therefore clang-tidy is not used in the GCC build. agents: queue: "libcxx-builders" os: "linux" @@ -107,6 +109,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -124,6 +127,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -141,6 +145,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -158,6 +163,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -180,6 +186,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -197,6 +204,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -214,6 +222,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -232,6 +241,8 @@ env: CC: "gcc-${GCC_STABLE_VERSION}" CXX: "g++-${GCC_STABLE_VERSION}" + # Some of GCC's warning flags are not supported by clang-tidy. + # Therefore clang-tidy is not used in the GCC build. agents: queue: "libcxx-builders" os: "linux" @@ -249,6 +260,7 @@ env: CC: "clang-14" CXX: "clang++-14" + CLANG_TIDY: "/usr/bin/clang-tidy-14" agents: queue: "libcxx-builders" os: "linux" @@ -266,6 +278,7 @@ env: CC: "clang-15" CXX: "clang++-15" + CLANG_TIDY: "/usr/bin/clang-tidy-15" agents: queue: "libcxx-builders" os: "linux" @@ -286,6 +299,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -303,6 +317,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -320,6 +335,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -337,6 +353,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -356,6 +373,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}" CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics" agents: @@ -376,6 +394,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -393,6 +412,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -410,6 +430,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -427,6 +448,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -444,6 +466,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -461,6 +484,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -480,6 +504,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -497,6 +522,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -514,6 +540,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -531,6 +558,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -548,6 +576,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -565,6 +594,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -582,6 +612,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -599,6 +630,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -616,6 +648,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" @@ -633,6 +666,7 @@ env: CC: "clang-${LLVM_HEAD_VERSION}" CXX: "clang++-${LLVM_HEAD_VERSION}" + CLANG_TIDY: "/usr/bin/clang-tidy-${LLVM_STABLE_VERSION}" agents: queue: "libcxx-builders" os: "linux" diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -32,9 +32,29 @@ them from Green Dragon. This is only relevant at all when running back-deployment testing if one wants to override the old dylibs we use to run the tests with different ones. +Environment variables +CC The C compiler to use, this value is used by CMake. This + variable is optional. +CXX The C++ compiler to use, this value is used by CMake. This + variable is optional. + +GIT_CLANG_FORMAT The git-clang-format binary to use in the 'format' builder. + When the value is omitted, it defaults to + 'git-clang-format'. This variable or its fallback must work + when running the 'format' builder. +CLANG_TIDY The clang-tidy binary to use in the unit tests. When the + value is omitted, it defaults to 'clang-tidy.exe' on Windows + and 'clang-tidy' on other platforms. The unit test validate + whether the executable can be used, if not the tests + requiring clang-tidy are unsupported. EOF } +if [[ $# == 0 ]]; then + usage + exit 0 +fi + while [[ $# -gt 0 ]]; do case ${1} in -h|--help) @@ -91,9 +111,13 @@ } function generate-cmake() { + if [ -z "${CLANG_TIDY}" ]; then + CLANG_TIDY=clang-tidy + fi generate-cmake-base \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ -DLIBCXX_CXX_ABI=libcxxabi \ + -DLIBCXX_TEST_CLANG_TIDY="${CLANG_TIDY}" \ "${@}" } @@ -105,12 +129,16 @@ # -D_LIBCPP_HAS_NO_INT128 (both when building the library itself and # when building tests) to allow enabling filesystem for running tests, # even if it uses a non-permanent ABI. + if [ -z "${CLANG_TIDY}" ]; then + CLANG_TIDY=clang-tidy.exe + fi generate-cmake-base \ -DLLVM_ENABLE_RUNTIMES="libcxx" \ -DCMAKE_C_COMPILER=clang-cl \ -DCMAKE_CXX_COMPILER=clang-cl \ -DLIBCXX_ENABLE_FILESYSTEM=YES \ -DLIBCXX_EXTRA_SITE_DEFINES="_LIBCPP_HAS_NO_INT128" \ + -DLIBCXX_TEST_CLANG_TIDY="${CLANG_TIDY}" \ "${@}" } diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -20,13 +20,13 @@ def _hasSuitableClangTidy(cfg): try: - return int(re.search('[0-9]+', commandOutput(cfg, ['clang-tidy --version'])).group()) >= 13 + return int(re.search('[0-9]+', commandOutput(cfg, ['%{clang-tidy} --version'])).group()) >= 14 except ConfigurationRuntimeError: return False def _hasSuitableClangQuery(cfg): try: - return int(re.search('[0-9]+', commandOutput(cfg, ['clang-query --version'])).group()) >= 13 + return int(re.search('[0-9]+', commandOutput(cfg, ['clang-query --version'])).group()) >= 14 except ConfigurationRuntimeError: return False