[llvm] [UTC][NFC] Indent switch cases (PR #165212)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 01:24:14 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-testing-tools
Author: Kunqiu Chen (Camsyn)
<details>
<summary>Changes</summary>
LLVM prints switch cases indented by 2 additional spaces, as follows:
```LLVM
switch i32 %x, label %default [
i32 0, label %phi
i32 1, label %phi
]
```
Since this only changes the output IR of update_test_checks.py and does not change the logic of the File Check Pattern, there seems to be no need to update the existing test cases.
---
Full diff: https://github.com/llvm/llvm-project/pull/165212.diff
2 Files Affected:
- (modified) llvm/utils/UpdateTestChecks/common.py (+1)
- (modified) llvm/utils/update_test_checks.py (+7-2)
``````````diff
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index a5e3c39bfdecd..1ba716112f527 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -606,6 +606,7 @@ def invoke_tool(exe, cmd_args, ir, preprocess_cmd=None, verbose=False):
DEBUG_ONLY_ARG_RE = re.compile(r"-debug-only[= ]([^ ]+)")
IS_DEBUG_RECORD_RE = re.compile(r"^(\s+)#dbg_")
+IS_SWITCH_CASE_RE = re.compile(r"^\s+i\d{1,2} \d+, label %\w+")
SCRUB_LEADING_WHITESPACE_RE = re.compile(r"^(\s+)")
SCRUB_WHITESPACE_RE = re.compile(r"(?!^(| \w))[ \t]+", flags=re.M)
diff --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py
index 3b562fbc54f78..37d046e53aa82 100755
--- a/llvm/utils/update_test_checks.py
+++ b/llvm/utils/update_test_checks.py
@@ -260,9 +260,14 @@ def update_test(ti: common.TestInfo):
skip_same_checks=dropped_previous_line,
):
# This input line of the function body will go as-is into the output.
- # Except make leading whitespace uniform: 2 spaces. 4 for debug records.
+ # Except make leading whitespace uniform: 2 spaces. 4 for debug records/switch cases.
indent = (
- " " if not common.IS_DEBUG_RECORD_RE.match(input_line) else " "
+ " " * 4
+ if (
+ common.IS_DEBUG_RECORD_RE.match(input_line)
+ or common.IS_SWITCH_CASE_RE.match(input_line)
+ )
+ else " " * 2
)
input_line = common.SCRUB_LEADING_WHITESPACE_RE.sub(indent, input_line)
output_lines.append(input_line)
``````````
</details>
https://github.com/llvm/llvm-project/pull/165212
More information about the llvm-commits
mailing list