aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2023-11-09 17:18:11 +0000
committerGitHub <noreply@github.com>2023-11-09 17:18:11 +0000
commit24839c32539bab96f972c9736a6e43de951449e6 (patch)
tree8f53d5fd84d7945c97ca36f672a48c695a6ad372 /llvm/utils/UpdateTestChecks/common.py
parent24577bd089c94d607de0d3df1b4259a28e7e23f5 (diff)
downloadllvm-24839c32539bab96f972c9736a6e43de951449e6.zip
llvm-24839c32539bab96f972c9736a6e43de951449e6.tar.gz
llvm-24839c32539bab96f972c9736a6e43de951449e6.tar.bz2
[UTC] Escape multiple {{ or }} in input for check lines. (#71790)
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.
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r--llvm/utils/UpdateTestChecks/common.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 74044f9..88b2ccc2 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -1171,6 +1171,9 @@ def generalize_check_lines_common(
return match.group(1) + rv + match.group(match.lastindex)
lines_with_def = []
+ multiple_braces_re = re.compile(r"({{+)|(}}+)")
+ def escape_braces(match_obj):
+ return '{{' + re.escape(match_obj.group(0)) + '}}'
for i, line in enumerate(lines):
if not is_asm and not is_analyze:
@@ -1200,6 +1203,10 @@ def generalize_check_lines_common(
(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(escape_braces, lines[i])
+ lines[i] = scrubbed_line
return lines