Skip to content

update_test_checks: indent dbg records #139230

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

Merged
merged 3 commits into from
May 9, 2025

Conversation

OCHyams
Copy link
Contributor

@OCHyams OCHyams commented May 9, 2025

LLVM prints debug records like #dbg_value indented 2 additional spaces.

@OCHyams OCHyams requested a review from SLTozer May 9, 2025 09:29
@llvmbot
Copy link
Member

llvmbot commented May 9, 2025

@llvm/pr-subscribers-testing-tools

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

LLVM prints debug records like #dbg_value indented 2 additional spaces.


Full diff: https://github.com/llvm/llvm-project/pull/139230.diff

2 Files Affected:

  • (modified) llvm/utils/UpdateTestChecks/common.py (+2)
  • (modified) llvm/utils/update_test_checks.py (+3-2)
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index e747ae3f385a9..d150612dd368e 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -602,6 +602,8 @@ def invoke_tool(exe, cmd_args, ir, preprocess_cmd=None, verbose=False):
 MARCH_ARG_RE = re.compile(r"-march[= ]([^ ]+)")
 DEBUG_ONLY_ARG_RE = re.compile(r"-debug-only[= ]([^ ]+)")
 
+IS_DEBUG_RECORD_RE = re.compile(r"^(\s+)#dbg_")
+
 SCRUB_LEADING_WHITESPACE_RE = re.compile(r"^(\s+)")
 SCRUB_WHITESPACE_RE = re.compile(r"(?!^(|  \w))[ \t]+", flags=re.M)
 SCRUB_PRESERVE_LEADING_WHITESPACE_RE = re.compile(r"((?!^)[ \t]*(\S))[ \t]+")
diff --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py
index f4b45c5581c71..a544a565aa42d 100755
--- a/llvm/utils/update_test_checks.py
+++ b/llvm/utils/update_test_checks.py
@@ -251,8 +251,9 @@ 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.
-                input_line = common.SCRUB_LEADING_WHITESPACE_RE.sub(r"  ", input_line)
+                # Except make leading whitespace uniform: 2 spaces. 4 for debug records.
+                indent = "  " if not common.IS_DEBUG_RECORD_RE.match(input_line) else "    "
+                input_line = common.SCRUB_LEADING_WHITESPACE_RE.sub(indent, input_line)
                 output_lines.append(input_line)
                 dropped_previous_line = False
                 if input_line.strip() == "}":

Copy link

github-actions bot commented May 9, 2025

✅ With the latest revision this PR passed the Python code formatter.

@OCHyams OCHyams requested review from nikic and jmorse May 9, 2025 09:58
@OCHyams OCHyams merged commit 234ae9b into llvm:main May 9, 2025
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants