-
Notifications
You must be signed in to change notification settings - Fork 15k
[UTC] Indent switch cases #165212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UTC] Indent switch cases #165212
Conversation
|
@llvm/pr-subscribers-testing-tools Author: Kunqiu Chen (Camsyn) ChangesLLVM prints switch cases indented by 2 additional spaces, as follows: 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:
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)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a UTC test for this (see llvm/test/tools/UpdateTestChecks/).
I'd also consider gating this under a new UTC version. I think this will produce just enough test churn to be annoying.
llvm/utils/update_test_checks.py
Outdated
| " " * 4 | ||
| if ( | ||
| common.IS_DEBUG_RECORD_RE.match(input_line) | ||
| or common.IS_SWITCH_CASE_RE.match(input_line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also consider gating this under a new UTC version. I think this will produce just enough test churn to be annoying.
Do you mean some change like this?
| or common.IS_SWITCH_CASE_RE.match(input_line) | |
| or ( | |
| ti.args.version > 4 | |
| and common.IS_SWITCH_CASE_RE.match(input_line) | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, though it would be > 6, see
| 6: The semantics of TBAA checks has been incorporated in the check lines. |
144da61 to
a9da88c
Compare
d9b16c3 to
01b0ca9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
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.
LLVM prints switch cases indented by 2 additional spaces, as follows:
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.