[tools] Update update_test_prefix.py to handle %s after prefixes
authorMircea Trofin <mtrofin@google.com>
Thu, 3 Dec 2020 05:32:28 +0000 (21:32 -0800)
committerMircea Trofin <mtrofin@google.com>
Fri, 4 Dec 2020 04:07:28 +0000 (20:07 -0800)
Sometimes the check-prefixes is followed by %s, and we want to keep a
white space before it.

Differential Revision: https://reviews.llvm.org/D92542

llvm/utils/update_test_prefix.py

index 9d383ca..28122cc 100755 (executable)
@@ -18,8 +18,7 @@ def remove_prefix(i, d=0):
             s = re.sub(',' + p + '([, \n])', '\\1', s)
             s = re.sub('\s+-?-check-prefix=' + p + '([ \n])', '\\1', s)
         else:
-            s = re.sub('-?-check-prefixes=([^, ]+\n)', '--check-prefix=\\1', s)
-            s = re.sub('-?-check-prefixes=([^, ]+) ', '--check-prefix=\\1', s)
+            s = re.sub('-?-check-prefixes=([\w-]+)(\Z|[ \t\n])', '--check-prefix=\\1\\2', s)
             t = re.search('-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)', s)
             while t:
                 s = re.sub(t.group(), '--check-prefixes=' + t.group(1) + ',' + t.group(2), s)