[libcxx-commits] [libcxx] [libc++][test] Raise a useful error when no -std=c++NN flag is found to work (PR #99423)

Janet Cobb via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 17 20:22:20 PDT 2024


https://github.com/randomnetcat updated https://github.com/llvm/llvm-project/pull/99423

>From 33db30b634a81c869f4ee53c42a629e681c3c57c Mon Sep 17 00:00:00 2001
From: Janet Cobb <git at randomcat.org>
Date: Wed, 17 Jul 2024 23:03:52 -0400
Subject: [PATCH 1/2] Raise a useful error when no -std=c++NN flag is detected

---
 libcxx/utils/libcxx/test/params.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 3aadc54cf92dc..320d550a0dc50 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -87,6 +87,15 @@ def getStdFlag(cfg, std):
         return "-std=" + fallbacks[std]
     return None
 
+def getDefaultStdValue(cfg):
+    viable = [s for s in reversed(_allStandards) if getStdFlag(cfg, s)]
+
+    if not viable:
+        raise RuntimeError(
+            "Unable to successfully detect the presence of any -std=c++NN flag. This likely indicates an issue with your compiler."
+        )
+
+    return viable[0]
 
 def getSpeedOptimizationFlag(cfg):
     if _isClang(cfg) or _isAppleClang(cfg) or _isGCC(cfg):
@@ -170,9 +179,7 @@ def getSuitableClangTidy(cfg):
         choices=_allStandards,
         type=str,
         help="The version of the standard to compile the test suite with.",
-        default=lambda cfg: next(
-            s for s in reversed(_allStandards) if getStdFlag(cfg, s)
-        ),
+        default=lambda cfg: getDefaultStdValue(cfg),
         actions=lambda std: [
             AddFeature(std),
             AddSubstitution("%{cxx_std}", re.sub(r"\+", "x", std)),

>From 9b2d21896f2a9ad44281917b4baa166b1845cc5d Mon Sep 17 00:00:00 2001
From: Janet Cobb <git at randomcat.org>
Date: Wed, 17 Jul 2024 23:22:09 -0400
Subject: [PATCH 2/2] Fix formatting issues

---
 libcxx/utils/libcxx/test/params.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 320d550a0dc50..13c7297fd7304 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -87,6 +87,7 @@ def getStdFlag(cfg, std):
         return "-std=" + fallbacks[std]
     return None
 
+
 def getDefaultStdValue(cfg):
     viable = [s for s in reversed(_allStandards) if getStdFlag(cfg, s)]
 
@@ -97,6 +98,7 @@ def getDefaultStdValue(cfg):
 
     return viable[0]
 
+
 def getSpeedOptimizationFlag(cfg):
     if _isClang(cfg) or _isAppleClang(cfg) or _isGCC(cfg):
         return "-O3"



More information about the libcxx-commits mailing list