https://github.com/matteo-rm created https://github.com/llvm/llvm-project/pull/238255
Handle run lines containing lit `%if`s by ignoring the condition and unwrapping, similar to other update scripts. From 80490465a16a8d4819d383ad916a7454fe46d028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Rizza=20Murgier?= <[email protected]> Date: Tue, 3 Nov 2026 00:06:35 +0100 Subject: [PATCH] [UpdateTestChecks] Handle lit's %if in update_cc_test_checks.py --- clang/test/utils/update_cc_test_checks/Inputs/lit-if.c | 4 ++++ .../update_cc_test_checks/Inputs/lit-if.c.expected | 9 +++++++++ clang/test/utils/update_cc_test_checks/lit-if.test | 4 ++++ llvm/utils/UpdateTestChecks/common.py | 10 ++++++++-- llvm/utils/update_cc_test_checks.py | 2 +- 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 clang/test/utils/update_cc_test_checks/Inputs/lit-if.c create mode 100644 clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected create mode 100644 clang/test/utils/update_cc_test_checks/lit-if.test 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]) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
