[libcxx-commits] [libcxx] f7679bc - [libc++][NFC] Reformat params.py

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 15 11:46:18 PDT 2023


Author: Louis Dionne
Date: 2023-06-15T14:46:14-04:00
New Revision: f7679bcfb6e246e44a8a74e015dccee387315530

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

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

After the Black reformatting changes, the code became pretty hard to
read and inconsistently formatted. This fixes that.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 7de8078b594d9..a23d833e56904 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -83,6 +83,7 @@ def getModuleFlag(cfg, enable_modules):
     return None
 
 
+# fmt: off
 DEFAULT_PARAMETERS = [
     Parameter(
         name="target_triple",
@@ -122,9 +123,7 @@ def getModuleFlag(cfg, enable_modules):
         actions=lambda enable_modules: [
             AddFeature("modules-build"),
             AddCompileFlag("-fmodules"),
-            AddCompileFlag(
-                "-fcxx-modules"
-            ),  # AppleClang disregards -fmodules entirely when compiling C++. This enables modules for C++.
+            AddCompileFlag("-fcxx-modules"), # AppleClang disregards -fmodules entirely when compiling C++. This enables modules for C++.
         ]
         if enable_modules == "clang"
         else [
@@ -148,11 +147,9 @@ def getModuleFlag(cfg, enable_modules):
         type=bool,
         default=False,
         help="Whether to enable Local Submodule Visibility in the Modules build.",
-        actions=lambda lsv: [
+        actions=lambda lsv: [] if not lsv else [
             AddCompileFlag("-Xclang -fmodules-local-submodule-visibility"),
-        ]
-        if lsv
-        else [],
+        ],
     ),
     Parameter(
         name="enable_exceptions",
@@ -160,9 +157,10 @@ def getModuleFlag(cfg, enable_modules):
         type=bool,
         default=True,
         help="Whether to enable exceptions when compiling the test suite.",
-        actions=lambda exceptions: []
-        if exceptions
-        else [AddFeature("no-exceptions"), AddCompileFlag("-fno-exceptions")],
+        actions=lambda exceptions: [] if exceptions else [
+            AddFeature("no-exceptions"),
+            AddCompileFlag("-fno-exceptions")
+        ],
     ),
     Parameter(
         name="enable_rtti",
@@ -170,9 +168,10 @@ def getModuleFlag(cfg, enable_modules):
         type=bool,
         default=True,
         help="Whether to enable RTTI when compiling the test suite.",
-        actions=lambda rtti: []
-        if rtti
-        else [AddFeature("no-rtti"), AddCompileFlag("-fno-rtti")],
+        actions=lambda rtti: [] if rtti else [
+            AddFeature("no-rtti"),
+            AddCompileFlag("-fno-rtti")
+        ],
     ),
     Parameter(
         name="stdlib",
@@ -199,9 +198,7 @@ def getModuleFlag(cfg, enable_modules):
                 AddFeature("stdlib={}".format(stdlib)),
                 # Also add an umbrella feature 'stdlib=libc++' for all flavors of libc++, to simplify
                 # the test suite.
-                AddFeature("stdlib=libc++")
-                if re.match(".+-libc\+\+", stdlib)
-                else None,
+                AddFeature("stdlib=libc++") if re.match(".+-libc\+\+", stdlib) else None,
             ],
         ),
     ),
@@ -211,10 +208,9 @@ def getModuleFlag(cfg, enable_modules):
         type=bool,
         default=True,
         help="Whether to enable warnings when compiling the test suite.",
-        actions=lambda warnings: []
-        if not warnings
-        else [AddOptionalWarningFlag(w) for w in _warningFlags]
-        + [AddCompileFlag("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER")],
+        actions=lambda warnings: [] if not warnings else
+            [AddOptionalWarningFlag(w) for w in _warningFlags] +
+            [AddCompileFlag("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER")],
     ),
     Parameter(
         name="use_sanitizer",
@@ -236,35 +232,29 @@ def getModuleFlag(cfg, enable_modules):
             None,
             [
                 AddFlag("-g -fno-omit-frame-pointer") if sanitizer else None,
-                AddFlag(
-                    "-fsanitize=undefined -fno-sanitize=float-divide-by-zero -fno-sanitize-recover=all"
-                )
-                if sanitizer == "Undefined"
-                else None,
-                AddFeature("ubsan") if sanitizer == "Undefined" else None,
+
+                AddFlag("-fsanitize=undefined -fno-sanitize=float-divide-by-zero -fno-sanitize-recover=all") if sanitizer == "Undefined" else None,
+                AddFeature("ubsan")                                                                          if sanitizer == "Undefined" else None,
+
                 AddFlag("-fsanitize=address") if sanitizer == "Address" else None,
-                AddFeature("asan") if sanitizer == "Address" else None,
+                AddFeature("asan")            if sanitizer == "Address" else None,
+
                 AddFlag("-fsanitize=hwaddress") if sanitizer == "HWAddress" else None,
-                AddFeature("hwasan") if sanitizer == "HWAddress" else None,
-                AddFlag("-fsanitize=memory")
-                if sanitizer in ["Memory", "MemoryWithOrigins"]
-                else None,
-                AddFeature("msan")
-                if sanitizer in ["Memory", "MemoryWithOrigins"]
-                else None,
-                AddFlag("-fsanitize-memory-track-origins")
-                if sanitizer == "MemoryWithOrigins"
-                else None,
+                AddFeature("hwasan")            if sanitizer == "HWAddress" else None,
+
+                AddFlag("-fsanitize=memory")               if sanitizer in ["Memory", "MemoryWithOrigins"] else None,
+                AddFeature("msan")                         if sanitizer in ["Memory", "MemoryWithOrigins"] else None,
+                AddFlag("-fsanitize-memory-track-origins") if sanitizer == "MemoryWithOrigins" else None,
+
                 AddFlag("-fsanitize=thread") if sanitizer == "Thread" else None,
-                AddFeature("tsan") if sanitizer == "Thread" else None,
+                AddFeature("tsan")           if sanitizer == "Thread" else None,
+
                 AddFlag("-fsanitize=dataflow") if sanitizer == "DataFlow" else None,
-                AddFlag("-fsanitize=leaks") if sanitizer == "Leaks" else None,
-                AddFeature("sanitizer-new-delete")
-                if sanitizer
-                in ["Address", "HWAddress", "Memory", "MemoryWithOrigins", "Thread"]
-                else None,
-            ],
-        ),
+                AddFlag("-fsanitize=leaks")    if sanitizer == "Leaks" else None,
+
+                AddFeature("sanitizer-new-delete") if sanitizer in ["Address", "HWAddress", "Memory", "MemoryWithOrigins", "Thread"] else None,
+            ]
+        )
     ),
     Parameter(
         name="enable_experimental",
@@ -279,11 +269,7 @@ def getModuleFlag(cfg, enable_modules):
             # We can't check for the feature 'msvc' in available_features
             # as those features are added after processing parameters.
             AddFeature("c++experimental"),
-            PrependLinkFlag(
-                lambda cfg: "-llibc++experimental"
-                if _isMSVC(cfg)
-                else "-lc++experimental"
-            ),
+            PrependLinkFlag(lambda cfg: "-llibc++experimental" if _isMSVC(cfg) else "-lc++experimental"),
             AddCompileFlag("-D_LIBCPP_ENABLE_EXPERIMENTAL"),
         ]
         if experimental
@@ -306,12 +292,10 @@ def getModuleFlag(cfg, enable_modules):
         default=False,
         help="Whether to enable assertions when compiling the test suite. This is only meaningful when "
         "running the tests against libc++.",
-        actions=lambda assertions: [
+        actions=lambda assertions: [] if not assertions else [
             AddCompileFlag("-D_LIBCPP_ENABLE_ASSERTIONS=1"),
             AddFeature("libcpp-has-assertions"),
-        ]
-        if assertions
-        else [],
+        ],
     ),
     Parameter(
         name="additional_features",
@@ -330,11 +314,10 @@ def getModuleFlag(cfg, enable_modules):
         help="Whether to enable backwards-compatibility transitive includes when running the tests. This "
         "is provided to ensure that the trimmed-down version of libc++ does not bit-rot in between "
         "points at which we bulk-remove transitive includes.",
-        actions=lambda enabled: []
-        if enabled
-        else [
+        actions=lambda enabled: [] if enabled else [
             AddFeature("transitive-includes-disabled"),
             AddCompileFlag("-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES"),
         ],
     ),
 ]
+# fmt: on


        


More information about the libcxx-commits mailing list