[libc++][CI] Improves clang-(tidy|query) selection.
authorMark de Wever <koraq@xs4all.nl>
Wed, 7 Dec 2022 16:43:59 +0000 (17:43 +0100)
committerMark de Wever <koraq@xs4all.nl>
Wed, 28 Dec 2022 19:01:06 +0000 (20:01 +0100)
Hardcode the version of the tools used in the test feature script
instead of the tests. By changing the hard-coded location it's
easier to make the location flexible in the future.

Drive-by change
- The minimum required version for clang-query is now 15, which matches
  our future idea as outlined in the Dockerfile.
- The minimum required version for clang-tidy is now 16, which enables
  the new clang-tidy ADL plugin. This plugin is disabled for C++03
  due to false positives when using `noexcept`, which is not an operator
  in C++03.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D139545

libcxx/test/libcxx/clang_query.sh.cpp
libcxx/test/libcxx/clang_tidy.sh.cpp
libcxx/utils/ci/run-buildbot
libcxx/utils/libcxx/test/features.py

index 1364ff83271572829f9c5a78854135dd19992a88..704445960f2c99ba582f3941b2ad8fb86f4e3244 100644 (file)
@@ -13,7 +13,7 @@
 // The attributes hide_from_abi_of_visible.query relies on aren't applied on windows.
 // XFAIL: windows
 
-// RUN: clang-query -f %S/clang_query/hide_from_abi_or_visible.query %s --use-color -- -Wno-unknown-warning-option %{compile_flags} -fno-modules > %t.output
+// RUN: %{clang-query} -f %S/clang_query/hide_from_abi_or_visible.query %s --use-color -- -Wno-unknown-warning-option %{compile_flags} -fno-modules > %t.output
 // RUN: cat %t.output
 // RUN: cat %t.output | wc -l | grep -Fxq 1
 
index 70a9026eafb811739d3db123a9a740cc31279449..7e4b88b91114bbe9ad68540b554431575c139854 100644 (file)
@@ -12,8 +12,8 @@
 // UNSUPPORTED: gcc
 
 // TODO: run clang-tidy with modules enabled once they are supported
-// RUN: clang-tidy %s --warnings-as-errors=* -header-filter=.* --checks='-*,libcpp-*' --load=%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin -- %{compile_flags} -fno-modules
-// 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=.* --checks='-*,libcpp-*' --load=%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin -- %{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 <ext/hash_map> from generating deprecated warnings for this test.
 #if defined(__DEPRECATED)
index 3ee025c19e06be8fe439cfea73a475447e350cb5..e17eaf18d50ad64b08431deaad69d9b03a625b9d 100755 (executable)
@@ -226,8 +226,9 @@ check-generated-output)
 #
 generic-cxx03)
     clean
-    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake" \
-                   -DLIBCXX_ENABLE_CLANG_TIDY=ON
+    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake"
+    #generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake" \
+    #               -DLIBCXX_ENABLE_CLANG_TIDY=ON
     check-runtimes
     check-abi-list
 ;;
index f122c75aa6799b564714ca4d499fb54763abcec7..094608c2a16eee56eb5f761cd8505cffba1e79a8 100644 (file)
@@ -18,19 +18,6 @@ _isGCC        = lambda cfg: '__GNUC__' in compilerMacros(cfg) and '__clang__' no
 _isMSVC       = lambda cfg: '_MSC_VER' in compilerMacros(cfg)
 _msvcVersion  = lambda cfg: (int(compilerMacros(cfg)['_MSC_VER']) // 100, int(compilerMacros(cfg)['_MSC_VER']) % 100)
 
-def _hasSuitableClangTidy(cfg):
-  try:
-    return int(re.search('[0-9]+', commandOutput(cfg, ['clang-tidy --version'])).group()) >= 13 and runScriptExitCode(
-      cfg, ['stat %{test-tools}/clang_tidy_checks/libcxx-tidy.plugin']) == 0
-  except ConfigurationRuntimeError:
-    return False
-
-def _hasSuitableClangQuery(cfg):
-  try:
-    return int(re.search('[0-9]+', commandOutput(cfg, ['clang-query --version'])).group()) >= 13
-  except ConfigurationRuntimeError:
-    return False
-
 DEFAULT_FEATURES = [
   Feature(name='fcoroutines-ts',
           when=lambda cfg: hasCompileFlag(cfg, '-fcoroutines-ts') and
@@ -154,9 +141,13 @@ DEFAULT_FEATURES = [
   Feature(name='executor-has-no-bash',
           when=lambda cfg: runScriptExitCode(cfg, ['%{exec} bash -c \'bash --version\'']) != 0),
   Feature(name='has-clang-tidy',
-          when=_hasSuitableClangTidy),
+          # TODO This should be the last stable release.
+          when=lambda cfg: runScriptExitCode(cfg, ['clang-tidy-16 --version']) == 0 and
+                           runScriptExitCode(cfg, ['stat %{test-tools}/clang_tidy_checks/libcxx-tidy.plugin']) == 0,
+          actions=[AddSubstitution('%{clang-tidy}', 'clang-tidy-16')]),
   Feature(name='has-clang-query',
-          when=_hasSuitableClangQuery),
+          when=lambda cfg: runScriptExitCode(cfg, ['clang-query-15 --version']) == 0,
+          actions=[AddSubstitution('%{clang-query}', 'clang-query-15')]),
 
   Feature(name='apple-clang',                                                                                                      when=_isAppleClang),
   Feature(name=lambda cfg: 'apple-clang-{__clang_major__}'.format(**compilerMacros(cfg)),                                          when=_isAppleClang),