From a8617034c4a7cc733676a31b736d3118fec34259 Mon Sep 17 00:00:00 2001 From: Hubert Tong 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. --- 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 000000000000..06b09ac9067a --- /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 49cbe8a8db61..e3e81fd1cf36 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