diff --git a/llvm/test/CodeGen/NVPTX/wmma.py b/llvm/test/CodeGen/NVPTX/wmma.py index e1e46f0b8cab3..8f6378e3ce3cc 100644 --- a/llvm/test/CodeGen/NVPTX/wmma.py +++ b/llvm/test/CodeGen/NVPTX/wmma.py @@ -847,7 +847,7 @@ def gen_check_unsupported_ops(items): ) print("; INTRINSICS: {{^; INTRINSICS_LIST_BEGIN}}") print( - """ + r""" ; NOEXTGEOM-NOT: {{m8n32|m32n8}} ; NOINT-NOT: .{{s32|s8}} diff --git a/llvm/tools/opt-viewer/opt-viewer.py b/llvm/tools/opt-viewer/opt-viewer.py index c9c7db726f765..2d32d66bbe3ae 100755 --- a/llvm/tools/opt-viewer/opt-viewer.py +++ b/llvm/tools/opt-viewer/opt-viewer.py @@ -135,7 +135,7 @@ def render_inline_remarks(self, r, line): # Column is the number of characters *including* tabs, keep those and # replace everything else with spaces. indent = line[: max(r.Column, 1) - 1] - indent = re.sub("\S", " ", indent) + indent = re.sub(r"\S", " ", indent) # Create expanded message and link if we have a multiline message. lines = r.message.split("\n") diff --git a/llvm/utils/DSAclean.py b/llvm/utils/DSAclean.py index 1b833ff893248..6937ca9e614f5 100755 --- a/llvm/utils/DSAclean.py +++ b/llvm/utils/DSAclean.py @@ -24,7 +24,7 @@ # it would kill old computers buffer = input.readline() while buffer != "": - if re.compile('label(\s*)=(\s*)"\s%tmp(.\w*)*(\s*)"').search(buffer): + if re.compile(r'label(\s*)=(\s*)"\s%tmp(.\w*)*(\s*)"').search(buffer): # skip next line, write neither this line nor the next buffer = input.readline() else: diff --git a/llvm/utils/DSAextract.py b/llvm/utils/DSAextract.py index 96f818bd2a831..9787922e5f674 100755 --- a/llvm/utils/DSAextract.py +++ b/llvm/utils/DSAextract.py @@ -69,7 +69,7 @@ # if this name is for the current node, add the dot variable name # for the node (it will be Node(hex number)) to our set of nodes if regexp.search(buffer): - node_set |= set([re.split("\s+", buffer, 2)[1]]) + node_set |= set([re.split(r"\s+", buffer, 2)[1]]) break buffer = input.readline() @@ -105,7 +105,7 @@ if nodes[0][:13] in node_set and nodes[1][:13] in node_set: output.write(buffer) elif nodeexp.search(buffer): # this is a node line - node = re.split("\s+", buffer, 2)[1] + node = re.split(r"\s+", buffer, 2)[1] if node in node_set: output.write(buffer) else: # this is a support line diff --git a/llvm/utils/add_argument_names.py b/llvm/utils/add_argument_names.py index 2860dd4b90bcb..af2f1297d9ee7 100755 --- a/llvm/utils/add_argument_names.py +++ b/llvm/utils/add_argument_names.py @@ -4,7 +4,7 @@ def fix_string(s): TYPE = re.compile( - '\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*' + 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*' ) counter = 0 diff --git a/llvm/utils/convert-constraint-log-to-z3.py b/llvm/utils/convert-constraint-log-to-z3.py index a3c33f2ef4599..f96ac3106f68b 100755 --- a/llvm/utils/convert-constraint-log-to-z3.py +++ b/llvm/utils/convert-constraint-log-to-z3.py @@ -46,7 +46,7 @@ def main(): content = f.read() groups = content.split("---") - var_re = re.compile("x\d+") + var_re = re.compile(r"x\d+") print("from z3 import *") for group in groups: diff --git a/llvm/utils/extract_vplan.py b/llvm/utils/extract_vplan.py index cff6f5074d771..96b9fd1b9a936 100755 --- a/llvm/utils/extract_vplan.py +++ b/llvm/utils/extract_vplan.py @@ -24,7 +24,7 @@ matches = re.findall(pattern, sys.stdin.read()) for vplan in matches: - m = re.search("graph \[.+(VF=.+,UF.+)", vplan) + m = re.search(r"graph \[.+(VF=.+,UF.+)", vplan) if not m: raise ValueError("Can't get the right VPlan name") name = re.sub("[^a-zA-Z0-9]", "", m.group(1)) diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py index da467f46b4dd3..ef6032c524c28 100755 --- a/llvm/utils/git/github-automation.py +++ b/llvm/utils/git/github-automation.py @@ -53,9 +53,9 @@ def escape_description(str): # https://github.com/github/markup/issues/1168#issuecomment-494946168 str = html.escape(str, False) # '@' followed by alphanum is a user name - str = re.sub("@(?=\w)", "@", str) + str = re.sub(r"@(?=\w)", "@", str) # '#' followed by digits is considered an issue number - str = re.sub("#(?=\d)", "#", str) + str = re.sub(r"#(?=\d)", "#", str) return str @@ -474,7 +474,7 @@ def issue_remove_cherry_pick_failed_label(self): def get_main_commit(self, cherry_pick_sha: str) -> github.Commit.Commit: commit = self.repo.get_commit(cherry_pick_sha) message = commit.commit.message - m = re.search("\(cherry picked from commit ([0-9a-f]+)\)", message) + m = re.search(r"\(cherry picked from commit ([0-9a-f]+)\)", message) if not m: return None return self.repo.get_commit(m.group(1)) diff --git a/llvm/utils/indirect_calls.py b/llvm/utils/indirect_calls.py index c18cffb26e7ae..0c123cc143ab1 100755 --- a/llvm/utils/indirect_calls.py +++ b/llvm/utils/indirect_calls.py @@ -33,7 +33,7 @@ def look_for_indirect(file): for line in stdout.splitlines(): if not line.startswith(" "): function = line - result = re.search("(call|jmp).*\*", line) + result = re.search(r"(call|jmp).*\*", line) if result is not None: # TODO: Perhaps use cxxfilt to demangle functions? print(function) diff --git a/llvm/utils/relative_lines.py b/llvm/utils/relative_lines.py index 86b190d5ea182..d4c2d9d0429b9 100755 --- a/llvm/utils/relative_lines.py +++ b/llvm/utils/relative_lines.py @@ -17,8 +17,8 @@ USAGE = """Example usage: find -type f clang/test/CodeCompletion | grep -v /Inputs/ | \\ xargs relative_lines.py --dry-run --verbose --near=100 \\ - --pattern='-code-completion-at[ =]%s:(\d+)' \\ - --pattern='requires fix-it: {(\d+):\d+-(\d+):\d+}' + --pattern='-code-completion-at[ =]%s:(\\d+)' \\ + --pattern='requires fix-it: {(\\d+):\\d+-(\\d+):\\d+}' """ import argparse diff --git a/llvm/utils/update_test_prefix.py b/llvm/utils/update_test_prefix.py index 434dc84fa4fc0..d11f2ae43abc4 100755 --- a/llvm/utils/update_test_prefix.py +++ b/llvm/utils/update_test_prefix.py @@ -17,13 +17,13 @@ def remove_prefix(i, d=0): p = r.group(1) s = re.sub("=" + p + ",", "=", s) s = re.sub("," + p + "([, \n])", "\\1", s) - s = re.sub("\s+-?-check-prefix=" + p + "([ \n])", "\\1", s) + s = re.sub("\\s+-?-check-prefix=" + p + "([ \n])", "\\1", s) else: s = re.sub( - "-?-check-prefixes=([\w-]+)(\Z|[ \t\n])", "--check-prefix=\\1\\2", s + "-?-check-prefixes=([\\w-]+)(\\Z|[ \t\n])", "--check-prefix=\\1\\2", s ) t = re.search( - "-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)", + r"-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)", s, ) while t: @@ -31,10 +31,10 @@ def remove_prefix(i, d=0): t.group(), "--check-prefixes=" + t.group(1) + "," + t.group(2), s ) t = re.search( - "-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)", + r"-?-check-(?:prefix|prefixes)=([^ ]+)\s+-?-check-(?:prefix|prefixes)=([^ ]+)", s, ) - s = re.sub("\s+-?-check-prefix=CHECK[ \t]*\n", "\n", s) + s = re.sub("\\s+-?-check-prefix=CHECK[ \t]*\n", "\n", s) f.truncate(0) f.seek(0) f.write(s)