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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 08:50:56 PST 2023


================
@@ -1171,6 +1171,15 @@ def transform_line_vars(match):
         return match.group(1) + rv + match.group(match.lastindex)
 
     lines_with_def = []
+    multiple_braces_re = re.compile(r"({{+)|(}}+)")
+    def escape_braces(match_obj):
+        s = match_obj.group(0)
+        escaped = ''
+        if s[0] == '{':
+            escaped = s.replace('{', '\\{')
+        else:
+            escaped = s.replace('}', '\\}')
+        return ''.join(['{{', escaped, '}}'])
----------------
fhahn wrote:

That works well, we just need to manually add the wrapping `{{` / `}}`

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


More information about the llvm-commits mailing list