[libcxx-commits] [PATCH] D141241: [libc++] Add clang-tidy to the list of possible substitutions for %{clang-tidy}

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jan 12 15:16:49 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf70a81cced3a: [libc++] Add clang-tidy to the list of possible substitutions for %{clang-tidy} (authored by philnik).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141241/new/

https://reviews.llvm.org/D141241

Files:
  libcxx/utils/libcxx/test/features.py


Index: libcxx/utils/libcxx/test/features.py
===================================================================
--- libcxx/utils/libcxx/test/features.py
+++ libcxx/utils/libcxx/test/features.py
@@ -18,6 +18,22 @@
 _isMSVC       = lambda cfg: '_MSC_VER' in compilerMacros(cfg)
 _msvcVersion  = lambda cfg: (int(compilerMacros(cfg)['_MSC_VER']) // 100, int(compilerMacros(cfg)['_MSC_VER']) % 100)
 
+def _getSuitableClangTidy(cfg):
+  try:
+    # If we didn't build the libcxx-tidy plugin via CMake, we can't run the clang-tidy tests.
+    if runScriptExitCode(cfg, ['stat %{test-tools}/clang_tidy_checks/libcxx-tidy.plugin']) != 0:
+      return None
+
+    # TODO This should be the last stable release.
+    if runScriptExitCode(cfg, ['clang-tidy-16 --version']) == 0:
+      return 'clang-tidy-16'
+
+    if int(re.search('[0-9]+', commandOutput(cfg, ['clang-tidy --version'])).group()) >= 16:
+      return 'clang-tidy'
+
+  except ConfigurationRuntimeError:
+    return None
+
 DEFAULT_FEATURES = [
   Feature(name='fcoroutines-ts',
           when=lambda cfg: hasCompileFlag(cfg, '-fcoroutines-ts') and
@@ -141,10 +157,8 @@
   Feature(name='executor-has-no-bash',
           when=lambda cfg: runScriptExitCode(cfg, ['%{exec} bash -c \'bash --version\'']) != 0),
   Feature(name='has-clang-tidy',
-          # 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')]),
+          when=lambda cfg: _getSuitableClangTidy(cfg) is not None,
+          actions=[AddSubstitution('%{clang-tidy}', lambda cfg: _getSuitableClangTidy(cfg))]),
   Feature(name='has-clang-query',
           when=lambda cfg: runScriptExitCode(cfg, ['clang-query-15 --version']) == 0,
           actions=[AddSubstitution('%{clang-query}', 'clang-query-15')]),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141241.488787.patch
Type: text/x-patch
Size: 2000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230112/090bf2dd/attachment.bin>


More information about the libcxx-commits mailing list