[libcxx-commits] [libcxx] 52310ce - [libc++][NFC] Reformat features.py

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 13 10:25:23 PDT 2023


Author: Louis Dionne
Date: 2023-06-13T10:24:46-07:00
New Revision: 52310ce9c1673cf01ebf8d77dc83b052c3b1b8c6

URL: https://github.com/llvm/llvm-project/commit/52310ce9c1673cf01ebf8d77dc83b052c3b1b8c6
DIFF: https://github.com/llvm/llvm-project/commit/52310ce9c1673cf01ebf8d77dc83b052c3b1b8c6.diff

LOG: [libc++][NFC] Reformat features.py

This file was reformatted using the Black tool, which led to entirely
unreadable code due to how lines are broken. Formatting tools are fine,
but not when they lead to code that humans have trouble reading. In the
case of features.py, a lot of it was meant to be aligned in a repetitive
but consistent way to make the structure of the code stand out.
Reformatting with the tool lost that property.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 082e6e79a500b..26ffb16262cf7 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -13,29 +13,17 @@
 import subprocess
 import sys
 
-_isClang = lambda cfg: "__clang__" in compilerMacros(
-    cfg
-) and "__apple_build_version__" not in compilerMacros(cfg)
+_isClang = lambda cfg: "__clang__" in compilerMacros(cfg) and "__apple_build_version__" not in compilerMacros(cfg)
 _isAppleClang = lambda cfg: "__apple_build_version__" in compilerMacros(cfg)
-_isGCC = lambda cfg: "__GNUC__" in compilerMacros(
-    cfg
-) and "__clang__" not in compilerMacros(cfg)
+_isGCC = lambda cfg: "__GNUC__" in compilerMacros(cfg) and "__clang__" not in compilerMacros(cfg)
 _isMSVC = lambda cfg: "_MSC_VER" in compilerMacros(cfg)
-_msvcVersion = lambda cfg: (
-    int(compilerMacros(cfg)["_MSC_VER"]) // 100,
-    int(compilerMacros(cfg)["_MSC_VER"]) % 100,
-)
+_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
-        ):
+        if runScriptExitCode(cfg, ["stat %{test-tools}/clang_tidy_checks/libcxx-tidy.plugin"]) != 0:
             return None
 
         # TODO MODULES require ToT due module specific fixes.
@@ -48,14 +36,7 @@ def _getSuitableClangTidy(cfg):
             return "clang-tidy-16"
 
         # LLVM RELEASE bump version
-        if (
-            int(
-                re.search(
-                    "[0-9]+", commandOutput(cfg, ["clang-tidy --version"])
-                ).group()
-            )
-            >= 16
-        ):
+        if int(re.search("[0-9]+", commandOutput(cfg, ["clang-tidy --version"])).group()) >= 16:
             return "clang-tidy"
 
     except ConfigurationRuntimeError:
@@ -237,8 +218,7 @@ def _getSuitableClangTidy(cfg):
     # manages to find binaries to execute.
     Feature(
         name="executor-has-no-bash",
-        when=lambda cfg: runScriptExitCode(cfg, ["%{exec} bash -c 'bash --version'"])
-        != 0,
+        when=lambda cfg: runScriptExitCode(cfg, ["%{exec} bash -c 'bash --version'"]) != 0,
     ),
     Feature(
         name="has-clang-tidy",
@@ -253,15 +233,11 @@ def _getSuitableClangTidy(cfg):
         when=_isAppleClang,
     ),
     Feature(
-        name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}".format(
-            **compilerMacros(cfg)
-        ),
+        name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}".format(**compilerMacros(cfg)),
         when=_isAppleClang,
     ),
     Feature(
-        name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(
-            **compilerMacros(cfg)
-        ),
+        name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(**compilerMacros(cfg)),
         when=_isAppleClang,
     ),
     Feature(name="clang", when=_isClang),
@@ -270,15 +246,11 @@ def _getSuitableClangTidy(cfg):
         when=_isClang,
     ),
     Feature(
-        name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}".format(
-            **compilerMacros(cfg)
-        ),
+        name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}".format(**compilerMacros(cfg)),
         when=_isClang,
     ),
     Feature(
-        name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(
-            **compilerMacros(cfg)
-        ),
+        name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(**compilerMacros(cfg)),
         when=_isClang,
     ),
     # Note: Due to a GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104760), we must disable deprecation warnings
@@ -301,15 +273,11 @@ def _getSuitableClangTidy(cfg):
         name=lambda cfg: "gcc-{__GNUC__}".format(**compilerMacros(cfg)), when=_isGCC
     ),
     Feature(
-        name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}".format(
-            **compilerMacros(cfg)
-        ),
+        name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}".format(**compilerMacros(cfg)),
         when=_isGCC,
     ),
     Feature(
-        name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}.{__GNUC_PATCHLEVEL__}".format(
-            **compilerMacros(cfg)
-        ),
+        name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}.{__GNUC_PATCHLEVEL__}".format(**compilerMacros(cfg)),
         when=_isGCC,
     ),
     Feature(name="msvc", when=_isMSVC),
@@ -344,8 +312,7 @@ def _getSuitableClangTidy(cfg):
 for macro, feature in macros.items():
     DEFAULT_FEATURES.append(
         Feature(
-            name=lambda cfg, m=macro, f=feature: f
-            + ("={}".format(compilerMacros(cfg)[m]) if compilerMacros(cfg)[m] else ""),
+            name=lambda cfg, m=macro, f=feature: f + ("={}".format(compilerMacros(cfg)[m]) if compilerMacros(cfg)[m] else ""),
             when=lambda cfg, m=macro: m in compilerMacros(cfg),
         )
     )


        


More information about the libcxx-commits mailing list