[llvm] update_test_checks: indent dbg records (PR #139230)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 9 02:30:04 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-testing-tools
Author: Orlando Cazalet-Hyams (OCHyams)
<details>
<summary>Changes</summary>
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
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() == "}":
``````````
</details>
https://github.com/llvm/llvm-project/pull/139230
More information about the llvm-commits
mailing list