[llvm] update_test_checks: indent dbg records (PR #139230)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Fri May 9 02:36:45 PDT 2025


https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/139230

>From a34ee52645b5a3818bff86c962bb66744925172d Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 9 May 2025 10:26:36 +0100
Subject: [PATCH 1/2] update_test_checks: indent dbg records

---
 llvm/utils/UpdateTestChecks/common.py | 2 ++
 llvm/utils/update_test_checks.py      | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

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() == "}":

>From cd7a16a88d10fb31048bed531ede18bff1efffa1 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 9 May 2025 10:36:19 +0100
Subject: [PATCH 2/2] fmt / darker

---
 llvm/utils/update_test_checks.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py
index a544a565aa42d..ff5bb7d782346 100755
--- a/llvm/utils/update_test_checks.py
+++ b/llvm/utils/update_test_checks.py
@@ -252,7 +252,9 @@ def update_test(ti: common.TestInfo):
             ):
                 # 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.
-                indent = "  " if not common.IS_DEBUG_RECORD_RE.match(input_line) else "    "
+                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



More information about the llvm-commits mailing list