[llvm] 7ad55a3 - [Utils][NFC] Fix regex substitution for update test checks

Giorgis Georgakoudis via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 24 17:49:19 PDT 2021


Author: Giorgis Georgakoudis
Date: 2021-03-24T17:47:33-07:00
New Revision: 7ad55a3df51a0d8c904fec3f52117932c23f0b01

URL: https://github.com/llvm/llvm-project/commit/7ad55a3df51a0d8c904fec3f52117932c23f0b01
DIFF: https://github.com/llvm/llvm-project/commit/7ad55a3df51a0d8c904fec3f52117932c23f0b01.diff

LOG: [Utils][NFC] Fix regex substitution for update test checks

Relates to: https://reviews.llvm.org/D97107

Added: 
    

Modified: 
    llvm/utils/UpdateTestChecks/common.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 38b5b1d96411..1940ac3e8153 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -362,8 +362,8 @@ def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
             func_repl = regex
             # Replace any capture groups with their matched strings.
             for g in match.groups():
-              func_repl = group_regex.sub(g, func_repl, count=1)
-            func = '{{' + func_repl + '}}'
+              func_repl = group_regex.sub(re.escape(g), func_repl, count=1)
+            func = re.sub(func_repl, '{{' + func_repl + '}}', func)
 
           # Replace all calls to regex matching functions.
           matches = re.finditer(regex, scrubbed_body)
@@ -371,7 +371,7 @@ def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
             func_repl = regex
             # Replace any capture groups with their matched strings.
             for g in match.groups():
-                func_repl = group_regex.sub(g, func_repl, count=1)
+                func_repl = group_regex.sub(re.escape(g), func_repl, count=1)
             # Substitute function call names that match the regex with the same
             # capture groups set.
             scrubbed_body = re.sub(func_repl, '{{' + func_repl + '}}', scrubbed_body)


        


More information about the llvm-commits mailing list