[clang] 03e2f03 - [UpdateTestChecks] Handle lit's %if in update_cc_test_checks.py (#238255)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 05:07:21 PST 2026
Author: Mattéo Rizza Murgier
Date: 2026-11-04T14:07:16+01:00
New Revision: 03e2f03d31b9d21b41e674343e1570ca18a5d030
URL: https://github.com/llvm/llvm-project/commit/03e2f03d31b9d21b41e674343e1570ca18a5d030
DIFF: https://github.com/llvm/llvm-project/commit/03e2f03d31b9d21b41e674343e1570ca18a5d030.diff
LOG: [UpdateTestChecks] Handle lit's %if in update_cc_test_checks.py (#238255)
Handle run lines containing lit `%if`s by ignoring the condition and
unwrapping, similar to other update scripts.
Added:
clang/test/utils/update_cc_test_checks/Inputs/lit-if.c
clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected
clang/test/utils/update_cc_test_checks/lit-if.test
Modified:
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_cc_test_checks.py
Removed:
################################################################################
diff --git a/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c
new file mode 100644
index 00000000000000..c277a98d66f028
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c
@@ -0,0 +1,4 @@
+// Check that the commands of a '%if' RUN line are run.
+// RUN: %if x86-registered-target %{ %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s %}
+
+void f(void) {}
diff --git a/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected
new file mode 100644
index 00000000000000..8b4eea71a5bc55
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected
@@ -0,0 +1,9 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// Check that the commands of a '%if' RUN line are run.
+// RUN: %if x86-registered-target %{ %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s %}
+
+// CHECK-LABEL: @f(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: ret void
+//
+void f(void) {}
diff --git a/clang/test/utils/update_cc_test_checks/lit-if.test b/clang/test/utils/update_cc_test_checks/lit-if.test
new file mode 100644
index 00000000000000..d4b6e1a40f9d05
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/lit-if.test
@@ -0,0 +1,4 @@
+## Test that the commands of a `%if` RUN line are run.
+
+# RUN: cp %S/Inputs/lit-if.c %t.c && %update_cc_test_checks %t.c
+# RUN:
diff -u %S/Inputs/lit-if.c.expected %t.c
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 2d1af7e2a11976..ca99009f232c96 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -507,13 +507,19 @@ def getSubstitutions(sourcepath):
]
-def split_run_line(run_line):
- """Split a FileCheck RUN line into its tool, FileCheck, and pre-processing commands."""
+def unwrap_lit_if(run_line):
+ """Return the commands of a `%if <condition> %{ <commands> %}` RUN line, without
+ evaluating the condition."""
if "%if" in run_line:
match = re.search(r"%{\s*(.*?)\s*%}", run_line)
if match:
run_line = match.group(1)
+ return run_line
+
+def split_run_line(run_line):
+ """Split a FileCheck RUN line into its tool, FileCheck, and pre-processing commands."""
+ run_line = unwrap_lit_if(run_line)
commands = [cmd.strip() for cmd in run_line.split("|")]
assert len(commands) >= 2
preprocess_cmd = " | ".join(commands[:-2]) or None
diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py
index cabdda9d5c0536..2bf8c52f5a7dff 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -318,7 +318,7 @@ def update_test(ti: common.TestInfo):
}
for l in ti.run_lines:
- commands = [cmd.strip() for cmd in l.split("|")]
+ commands = [cmd.strip() for cmd in common.unwrap_lit_if(l).split("|")]
triple_in_cmd = None
m = common.TRIPLE_ARG_RE.search(commands[0])
More information about the cfe-commits
mailing list