[llvm] [UTC] Escape multiple {{ or }} in input for check lines. (PR #71790)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 02:10:44 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-testing-tools

Author: Florian Hahn (fhahn)

<details>
<summary>Changes</summary>

SCEV expressions may contain multiple {{ or }} in the debug output, which needs escaping.

See llvm/test/Analysis/LoopAccessAnalysis/loops-with-indirect-reads-and-writes.ll for a test that needs escaping.

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


1 Files Affected:

- (modified) llvm/utils/UpdateTestChecks/common.py (+5) 


``````````diff
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 74044f925aadde4..e8d8d99257e81d0 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -1171,6 +1171,7 @@ def transform_line_vars(match):
         return match.group(1) + rv + match.group(match.lastindex)
 
     lines_with_def = []
+    multiple_braces_re = re.compile(r"(({{+)|(}}+))")
 
     for i, line in enumerate(lines):
         if not is_asm and not is_analyze:
@@ -1200,6 +1201,10 @@ def transform_line_vars(match):
                 (lines[i], changed) = nameless_value_regex.subn(
                     transform_line_vars, lines[i], count=1
                 )
+        if is_analyze:
+            # Escape multiple {{ or }} as {{}} denotes a FileCheck regex.
+            scrubbed_line = multiple_braces_re.sub(r"{{\\\1}}", lines[i])
+            lines[i] = scrubbed_line
     return lines
 
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/71790


More information about the llvm-commits mailing list