[libcxx-commits] [libcxx] [llvm] [RFC][libc++][test] Improves C++ Standard filtering. (PR #89499)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Apr 20 04:01:57 PDT 2024


https://github.com/mordante created https://github.com/llvm/llvm-project/pull/89499

This is a proof-of-concept how we could improve the C++ language filtering in lit. There will be a Discourse post for adding feedback on the approach.

>From 96cd69bc0562c718fdce9bd7ab76e6db13132978 Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Fri, 19 Apr 2024 20:31:19 +0200
Subject: [PATCH] [RFC][libc++][test] Improves C++ Standard filtering.

This is a proof-of-concept how we could improve the C++ language filtering
in lit. There will be a Discourse post for adding feedback on the
approach.
---
 .../print.fun/includes.compile.pass.cpp       |  2 +-
 .../print.fun/no_file_description.pass.cpp    |  2 +-
 .../locale.stdcvt/depr.verify.cpp             |  2 +-
 .../conversions.buffer/depr.verify.cpp        |  3 ++-
 .../conversions.string/depr.verify.cpp        |  2 +-
 .../reserve.deprecated_in_cxx20.verify.cpp    |  2 +-
 libcxx/utils/libcxx/test/params.py            | 21 +++++++++++++++++--
 llvm/utils/lit/lit/BooleanExpression.py       |  2 +-
 8 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/includes.compile.pass.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/includes.compile.pass.cpp
index 34eff101d730aa..5b1382a5a5b139 100644
--- a/libcxx/test/std/input.output/iostream.format/print.fun/includes.compile.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/print.fun/includes.compile.pass.cpp
@@ -5,7 +5,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// REQUIRES: >=c++23
 // UNSUPPORTED: no-filesystem
 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
 
diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/no_file_description.pass.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/no_file_description.pass.cpp
index ffa48c5e745d65..ea96305e7f89cd 100644
--- a/libcxx/test/std/input.output/iostream.format/print.fun/no_file_description.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/print.fun/no_file_description.pass.cpp
@@ -5,7 +5,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: <=c++20
 // UNSUPPORTED: no-filesystem
 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
 
diff --git a/libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp b/libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
index b3c6fc8674f8a2..a29b0c16e7fa01 100644
--- a/libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
+++ b/libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03, c++11, c++14, c++26
+// UNSUPPORTED: <=c++14, >=c++26
 // UNSUPPORTED: no-wide-characters
 
 // <codecvt>
diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
index cb067e99a4764b..0174b5b9efea6a 100644
--- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
+++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
@@ -6,7 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03, c++11, c++14, c++26
+// REQUIRES: >=c++17
+// UNSUPPORTED: >=c++26
 
 // XFAIL: no-wide-characters
 
diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
index f8bd156bdd5f6a..4b4714dea70bb4 100644
--- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
+++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
@@ -8,7 +8,7 @@
 
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT
 
-// UNSUPPORTED: c++03, c++11, c++14, c++26
+// UNSUPPORTED: <=c++14, >=c++26
 // UNSUPPORTED: no-wide-characters
 
 // <codecvt>
diff --git a/libcxx/test/std/strings/basic.string/string.capacity/reserve.deprecated_in_cxx20.verify.cpp b/libcxx/test/std/strings/basic.string/string.capacity/reserve.deprecated_in_cxx20.verify.cpp
index 81edd9b83d184d..9241d65a9d3e01 100644
--- a/libcxx/test/std/strings/basic.string/string.capacity/reserve.deprecated_in_cxx20.verify.cpp
+++ b/libcxx/test/std/strings/basic.string/string.capacity/reserve.deprecated_in_cxx20.verify.cpp
@@ -10,7 +10,7 @@
 
 // void reserve(); // Deprecated in C++20
 
-// UNSUPPORTED: c++03, c++11, c++14, c++17, c++26
+// UNSUPPORTED: <=c++17, >=c++26
 
 #include <string>
 
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index c2d294e49f4884..42ebc2657759d8 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -165,11 +165,28 @@ def getSuitableClangTidy(cfg):
         default=lambda cfg: next(
             s for s in reversed(_allStandards) if getStdFlag(cfg, s)
         ),
-        actions=lambda std: [
+        actions=lambda std: filter(None, [
             AddFeature(std),
+
+            AddFeature("<=c++03") if std <= "c++03" else None,
+            AddFeature("<=c++11") if std <= "c++11" else None,
+            AddFeature("<=c++14") if std <= "c++14" else None,
+            AddFeature("<=c++17") if std <= "c++17" else None,
+            AddFeature("<=c++20") if std <= "c++20" else None,
+            AddFeature("<=c++23") if std <= "c++23" else None,
+            AddFeature("<=c++26") if std <= "c++26" else None,
+
+            AddFeature(">=c++03") if std >= "c++03" else None,
+            AddFeature(">=c++11") if std >= "c++11" else None,
+            AddFeature(">=c++14") if std >= "c++14" else None,
+            AddFeature(">=c++17") if std >= "c++17" else None,
+            AddFeature(">=c++20") if std >= "c++20" else None,
+            AddFeature(">=c++23") if std >= "c++23" else None,
+            AddFeature(">=c++26") if std >= "c++26" else None,
+
             AddSubstitution("%{cxx_std}", re.sub(r"\+", "x", std)),
             AddCompileFlag(lambda cfg: getStdFlag(cfg, std)),
-        ],
+        ]),
     ),
     Parameter(
         name="optimization",
diff --git a/llvm/utils/lit/lit/BooleanExpression.py b/llvm/utils/lit/lit/BooleanExpression.py
index 9b9573d2f3f146..00ab282245e4ae 100644
--- a/llvm/utils/lit/lit/BooleanExpression.py
+++ b/llvm/utils/lit/lit/BooleanExpression.py
@@ -47,7 +47,7 @@ def __init__(self, string, variables):
 
     # Tokenization pattern.
     Pattern = re.compile(
-        r"\A\s*([()]|&&|\|\||!|(?:[-+=._a-zA-Z0-9]+|\{\{.+?\}\})+)\s*(.*)\Z"
+        r"\A\s*([()]|&&|\|\||!|(?:[-+<=>._a-zA-Z0-9]+|\{\{.+?\}\})+)\s*(.*)\Z"
     )
 
     @staticmethod



More information about the libcxx-commits mailing list