Skip to content

Commit 6efc4fa

Browse files
committed
fix(llvm/**.py): fix invalid escape sequences
1 parent d2ce9dc commit 6efc4fa

12 files changed

+31
-31
lines changed

llvm/test/CodeGen/NVPTX/wmma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ def gen_check_unsupported_ops(items):
847847
)
848848
print("; INTRINSICS: {{^; INTRINSICS_LIST_BEGIN}}")
849849
print(
850-
"""
850+
r"""
851851
852852
; NOEXTGEOM-NOT: {{m8n32|m32n8}}
853853
; NOINT-NOT: .{{s32|s8}}

llvm/tools/opt-viewer/opt-viewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def render_inline_remarks(self, r, line):
135135
# Column is the number of characters *including* tabs, keep those and
136136
# replace everything else with spaces.
137137
indent = line[: max(r.Column, 1) - 1]
138-
indent = re.sub("\S", " ", indent)
138+
indent = re.sub(r"\S", " ", indent)
139139

140140
# Create expanded message and link if we have a multiline message.
141141
lines = r.message.split("\n")

llvm/utils/DSAclean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# it would kill old computers
2525
buffer = input.readline()
2626
while buffer != "":
27-
if re.compile('label(\s*)=(\s*)"\s%tmp(.\w*)*(\s*)"').search(buffer):
27+
if re.compile(r'label(\s*)=(\s*)"\s%tmp(.\w*)*(\s*)"').search(buffer):
2828
# skip next line, write neither this line nor the next
2929
buffer = input.readline()
3030
else:

llvm/utils/DSAextract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# if this name is for the current node, add the dot variable name
7070
# for the node (it will be Node(hex number)) to our set of nodes
7171
if regexp.search(buffer):
72-
node_set |= set([re.split("\s+", buffer, 2)[1]])
72+
node_set |= set([re.split(r"\s+", buffer, 2)[1]])
7373
break
7474
buffer = input.readline()
7575

@@ -105,7 +105,7 @@
105105
if nodes[0][:13] in node_set and nodes[1][:13] in node_set:
106106
output.write(buffer)
107107
elif nodeexp.search(buffer): # this is a node line
108-
node = re.split("\s+", buffer, 2)[1]
108+
node = re.split(r"\s+", buffer, 2)[1]
109109
if node in node_set:
110110
output.write(buffer)
111111
else: # this is a support line

llvm/utils/add_argument_names.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def fix_string(s):
66
TYPE = re.compile(
7-
'\s*(i[0-9]+|float|double|x86_fp80|fp128|ppc_fp128|\[\[.*?\]\]|\[2 x \[\[[A-Z_0-9]+\]\]\]|<.*?>|{.*?}|\[[0-9]+ x .*?\]|%["a-z:A-Z0-9._]+({{.*?}})?|%{{.*?}}|{{.*?}}|\[\[.*?\]\])(\s*(\*|addrspace\(.*?\)|dereferenceable\(.*?\)|byval\(.*?\)|sret|zeroext|inreg|returned|signext|nocapture|align \d+|swiftself|swifterror|readonly|noalias|inalloca|nocapture))*\s*'
7+
r'\s*(i[0-9]+|float|double|x86_fp80|fp128|ppc_fp128|\[\[.*?\]\]|\[2 x \[\[[A-Z_0-9]+\]\]\]|<.*?>|{.*?}|\[[0-9]+ x .*?\]|%["a-z:A-Z0-9._]+({{.*?}})?|%{{.*?}}|{{.*?}}|\[\[.*?\]\])(\s*(\*|addrspace\(.*?\)|dereferenceable\(.*?\)|byval\(.*?\)|sret|zeroext|inreg|returned|signext|nocapture|align \d+|swiftself|swifterror|readonly|noalias|inalloca|nocapture))*\s*'
88
)
99

1010
counter = 0

llvm/utils/convert-constraint-log-to-z3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def main():
4646
content = f.read()
4747

4848
groups = content.split("---")
49-
var_re = re.compile("x\d+")
49+
var_re = re.compile(r"x\d+")
5050

5151
print("from z3 import *")
5252
for group in groups:

llvm/utils/extract_symbols.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ def nm_get_symbols(tool, lib):
5353
# The -P flag displays the size field for symbols only when applicable,
5454
# so the last field is optional. There's no space after the value field,
5555
# but \s+ match newline also, so \s+\S* will match the optional size field.
56-
match = re.match("^(\S+)\s+[BDGRSTuVW]\s+\S+\s+\S*$", line)
56+
match = re.match(r"^(\S+)\s+[BDGRSTuVW]\s+\S+\s+\S*$", line)
5757
if match:
5858
yield (match.group(1), True)
5959
# Look for undefined symbols, which have type U and may or may not
6060
# (depending on which nm is being used) have value and size.
61-
match = re.match("^(\S+)\s+U\s+(\S+\s+\S*)?$", line)
61+
match = re.match(r"^(\S+)\s+U\s+(\S+\s+\S*)?$", line)
6262
if match:
6363
yield (match.group(1), False)
6464
process.wait()
@@ -71,7 +71,7 @@ def readobj_is_32bit_windows(tool, lib):
7171
[tool, "--file-header", lib], universal_newlines=True
7272
)
7373
for line in output.splitlines():
74-
match = re.match("Format: (\S+)", line)
74+
match = re.match(r"Format: (\S+)", line)
7575
if match:
7676
return match.group(1) == "COFF-i386"
7777
return False
@@ -100,10 +100,10 @@ def should_keep_microsoft_symbol(symbol, calling_convention_decoration):
100100
# An anonymous namespace is mangled as ?A(maybe hex number)@. Any symbol
101101
# that mentions an anonymous namespace can be discarded, as the anonymous
102102
# namespace doesn't exist outside of that translation unit.
103-
elif re.search("\?A(0x\w+)?@", symbol):
103+
elif re.search(r"\?A(0x\w+)?@", symbol):
104104
return None
105105
# Skip X86GenMnemonicTables functions, they are not exposed from llvm/include/.
106-
elif re.match("\?is[A-Z0-9]*@X86@llvm", symbol):
106+
elif re.match(r"\?is[A-Z0-9]*@X86@llvm", symbol):
107107
return None
108108
# Keep mangled llvm:: and clang:: function symbols. How we detect these is a
109109
# bit of a mess and imprecise, but that avoids having to completely demangle
@@ -140,7 +140,7 @@ def should_keep_itanium_symbol(symbol, calling_convention_decoration):
140140
if not symbol.startswith("_") and not symbol.startswith("."):
141141
return symbol
142142
# Discard manglings that aren't nested names
143-
match = re.match("\.?_Z(T[VTIS])?(N.+)", symbol)
143+
match = re.match(r"\.?_Z(T[VTIS])?(N.+)", symbol)
144144
if not match:
145145
return None
146146
# Demangle the name. If the name is too complex then we don't need to keep
@@ -169,7 +169,7 @@ class TooComplexName(Exception):
169169
# (name, rest of string) pair.
170170
def parse_itanium_name(arg):
171171
# Check for a normal name
172-
match = re.match("(\d+)(.+)", arg)
172+
match = re.match(r"(\d+)(.+)", arg)
173173
if match:
174174
n = int(match.group(1))
175175
name = match.group(1) + match.group(2)[:n]
@@ -196,7 +196,7 @@ def skip_itanium_template(arg):
196196
tmp = arg[1:]
197197
while tmp:
198198
# Check for names
199-
match = re.match("(\d+)(.+)", tmp)
199+
match = re.match(r"(\d+)(.+)", tmp)
200200
if match:
201201
n = int(match.group(1))
202202
tmp = match.group(2)[n:]
@@ -280,19 +280,19 @@ def parse_microsoft_mangling(arg):
280280
if arg.startswith("@"):
281281
return components
282282
# Check for a simple name
283-
match = re.match("(\w+)@(.+)", arg)
283+
match = re.match(r"(\w+)@(.+)", arg)
284284
if match:
285285
components.append((match.group(1), False))
286286
arg = match.group(2)
287287
continue
288288
# Check for a special function name
289-
match = re.match("(\?_?\w)(.+)", arg)
289+
match = re.match(r"(\?_?\w)(.+)", arg)
290290
if match:
291291
components.append((match.group(1), False))
292292
arg = match.group(2)
293293
continue
294294
# Check for a template name
295-
match = re.match("\?\$(\w+)@[^@]+@(.+)", arg)
295+
match = re.match(r"\?\$(\w+)@[^@]+@(.+)", arg)
296296
if match:
297297
components.append((match.group(1), True))
298298
arg = match.group(2)
@@ -323,7 +323,7 @@ def get_template_name(sym, mangling):
323323
if mangling == "microsoft":
324324
names = parse_microsoft_mangling(sym)
325325
else:
326-
match = re.match("\.?_Z(T[VTIS])?(N.+)", sym)
326+
match = re.match(r"\.?_Z(T[VTIS])?(N.+)", sym)
327327
if match:
328328
names, _ = parse_itanium_nested_name(match.group(2))
329329
else:

llvm/utils/extract_vplan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
matches = re.findall(pattern, sys.stdin.read())
2525

2626
for vplan in matches:
27-
m = re.search("graph \[.+(VF=.+,UF.+)", vplan)
27+
m = re.search(r"graph \[.+(VF=.+,UF.+)", vplan)
2828
if not m:
2929
raise ValueError("Can't get the right VPlan name")
3030
name = re.sub("[^a-zA-Z0-9]", "", m.group(1))

llvm/utils/git/github-automation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def escape_description(str):
5353
# https://github.com/github/markup/issues/1168#issuecomment-494946168
5454
str = html.escape(str, False)
5555
# '@' followed by alphanum is a user name
56-
str = re.sub("@(?=\w)", "@<!-- -->", str)
56+
str = re.sub(r"@(?=\w)", "@<!-- -->", str)
5757
# '#' followed by digits is considered an issue number
58-
str = re.sub("#(?=\d)", "#<!-- -->", str)
58+
str = re.sub(r"#(?=\d)", "#<!-- -->", str)
5959
return str
6060

6161

@@ -474,7 +474,7 @@ def issue_remove_cherry_pick_failed_label(self):
474474
def get_main_commit(self, cherry_pick_sha: str) -> github.Commit.Commit:
475475
commit = self.repo.get_commit(cherry_pick_sha)
476476
message = commit.commit.message
477-
m = re.search("\(cherry picked from commit ([0-9a-f]+)\)", message)
477+
m = re.search(r"\(cherry picked from commit ([0-9a-f]+)\)", message)
478478
if not m:
479479
return None
480480
return self.repo.get_commit(m.group(1))

llvm/utils/indirect_calls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def look_for_indirect(file):
3333
for line in stdout.splitlines():
3434
if line.startswith(" ") == False:
3535
function = line
36-
result = re.search("(call|jmp).*\*", line)
36+
result = re.search(r"(call|jmp).*\*", line)
3737
if result is not None:
3838
# TODO: Perhaps use cxxfilt to demangle functions?
3939
print(function)

llvm/utils/relative_lines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
USAGE = """Example usage:
1818
find -type f clang/test/CodeCompletion | grep -v /Inputs/ | \\
1919
xargs relative_lines.py --dry-run --verbose --near=100 \\
20-
--pattern='-code-completion-at[ =]%s:(\d+)' \\
21-
--pattern='requires fix-it: {(\d+):\d+-(\d+):\d+}'
20+
--pattern='-code-completion-at[ =]%s:(\\d+)' \\
21+
--pattern='requires fix-it: {(\\d+):\\d+-(\\d+):\\d+}'
2222
"""
2323

2424
import argparse

llvm/utils/update_test_prefix.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ def remove_prefix(i, d=0):
1717
p = r.group(1)
1818
s = re.sub("=" + p + ",", "=", s)
1919
s = re.sub("," + p + "([, \n])", "\\1", s)
20-
s = re.sub("\s+-?-check-prefix=" + p + "([ \n])", "\\1", s)
20+
s = re.sub("\\s+-?-check-prefix=" + p + "([ \n])", "\\1", s)
2121
else:
2222
s = re.sub(
23-
"-?-check-prefixes=([\w-]+)(\Z|[ \t\n])", "--check-prefix=\\1\\2", s
23+
"-?-check-prefixes=([\\w-]+)(\\Z|[ \t\n])", "--check-prefix=\\1\\2", s
2424
)
2525
t = re.search(
26-
"-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)",
26+
r"-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)",
2727
s,
2828
)
2929
while t:
3030
s = re.sub(
3131
t.group(), "--check-prefixes=" + t.group(1) + "," + t.group(2), s
3232
)
3333
t = re.search(
34-
"-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)",
34+
r"-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)",
3535
s,
3636
)
37-
s = re.sub("\s+-?-check-prefix=CHECK[ \t]*\n", "\n", s)
37+
s = re.sub("\\s+-?-check-prefix=CHECK[ \t]*\n", "\n", s)
3838
f.truncate(0)
3939
f.seek(0)
4040
f.write(s)

0 commit comments

Comments
 (0)