[llvm-branch-commits] [libcxx] release/23.x: [libc++][utils] Fix LIT `%if` substitution support (#209358) (PR #211689)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jul 30 23:57:09 PDT 2026
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/211689
>From 834c3bcec496068372920790bbd571b4fa091c65 Mon Sep 17 00:00:00 2001
From: Hubert Tong <hubert.reinterpretcast at gmail.com>
Date: Mon, 20 Jul 2026 09:36:43 -0400
Subject: [PATCH] [libc++][utils] Fix LIT `%if` substitution support (#209358)
Update the applySubstitutions call in `libcxx/utils/libcxx/test/format.py` to match the
change to `llvm/utils/lit/lit/TestRunner.py` done in 1041a9642ba0.
(cherry picked from commit a8617034c4a7cc733676a31b736d3118fec34259)
---
libcxx/test/selftest/if-else.sh.cpp | 11 +++++++++++
libcxx/utils/libcxx/test/format.py | 6 +++++-
2 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 libcxx/test/selftest/if-else.sh.cpp
diff --git a/libcxx/test/selftest/if-else.sh.cpp b/libcxx/test/selftest/if-else.sh.cpp
new file mode 100644
index 0000000000000..06b09ac9067a5
--- /dev/null
+++ b/libcxx/test/selftest/if-else.sh.cpp
@@ -0,0 +1,11 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Make sure that LIT `%if` substitutions are aware of the available features.
+
+// RUN: not %if target={{.+}} %{ not %} echo "hello world"
diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py
index 49cbe8a8db618..e3e81fd1cf36f 100644
--- a/libcxx/utils/libcxx/test/format.py
+++ b/libcxx/utils/libcxx/test/format.py
@@ -205,8 +205,12 @@ def parseScript(test, preamble):
)
# Perform substitutions in the script itself.
+ conditions = {feature: True for feature in test.config.available_features}
script = lit.TestRunner.applySubstitutions(
- script, substitutions, recursion_limit=test.config.recursiveExpansionLimit
+ script,
+ substitutions,
+ conditions,
+ recursion_limit=test.config.recursiveExpansionLimit,
)
return script
More information about the llvm-branch-commits
mailing list