[libcxx-commits] [libcxx] b324798 - [libc++] Check clang-tidy version
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 2 09:42:16 PST 2022
Author: Nikolas Klauser
Date: 2022-03-02T18:42:04+01:00
New Revision: b324798fc8fb6e5990d803ceeee5f87fd8064cf1
URL: https://github.com/llvm/llvm-project/commit/b324798fc8fb6e5990d803ceeee5f87fd8064cf1
DIFF: https://github.com/llvm/llvm-project/commit/b324798fc8fb6e5990d803ceeee5f87fd8064cf1.diff
LOG: [libc++] Check clang-tidy version
Reviewed By: ldionne, #libc
Spies: libcxx-commits, arichardson
Differential Revision: https://reviews.llvm.org/D120087
Added:
Modified:
libcxx/utils/libcxx/test/dsl.py
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index 791edb3406fc9..db723fc2b3567 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -217,6 +217,21 @@ def runScriptExitCode(config, script):
_, _, exitCode, _ = _executeScriptInternal(test, script)
return exitCode
+ at _memoizeExpensiveOperation(lambda c, s: (c.substitutions, c.environment, s))
+def commandOutput(config, command):
+ """
+ Runs the given script as a Lit test, and returns the output.
+ If the exit code isn't 0 an exception is raised.
+
+ The script must be a list of commands, each of which being something that
+ could appear on the right-hand-side of a `RUN:` keyword.
+ """
+ with _makeConfigTest(config) as test:
+ out, _, exitCode, _ = _executeScriptInternal(test, command)
+ if exitCode != 0:
+ raise ConfigurationRuntimeError()
+ return out
+
@_memoizeExpensiveOperation(lambda c, l: (c.substitutions, c.environment, l))
def hasAnyLocale(config, locales):
"""
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 1c1d4fda97b84..a27647b05d625 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -18,6 +18,13 @@
_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
+ except ConfigurationRuntimeError:
+ return False
+
+
DEFAULT_FEATURES = [
Feature(name='fcoroutines-ts',
when=lambda cfg: hasCompileFlag(cfg, '-fcoroutines-ts') and
@@ -109,7 +116,7 @@
Feature(name='executor-has-no-bash',
when=lambda cfg: runScriptExitCode(cfg, ['%{exec} bash -c \'bash --version\'']) != 0),
Feature(name='has-clang-tidy',
- when=lambda cfg: runScriptExitCode(cfg, ['clang-tidy --version']) == 0),
+ when=_hasSuitableClangTidy),
Feature(name='apple-clang', when=_isAppleClang),
Feature(name=lambda cfg: 'apple-clang-{__clang_major__}'.format(**compilerMacros(cfg)), when=_isAppleClang),
More information about the libcxx-commits
mailing list