[llvm] fix(llvm/**.py): fix invalid escape sequences (PR #94035)
Eisuke Kawashima via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 25 12:08:39 PST 2024
https://github.com/e-kwsm updated https://github.com/llvm/llvm-project/pull/94035
>From e7dc07df6655462a7efa2f024c8bb667e72c1c78 Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima <e-kwsm at users.noreply.github.com>
Date: Sat, 11 May 2024 02:39:21 +0900
Subject: [PATCH] fix(llvm/**.py): fix invalid escape sequences
---
llvm/test/CodeGen/NVPTX/wmma.py | 2 +-
llvm/tools/opt-viewer/opt-viewer.py | 2 +-
llvm/utils/DSAclean.py | 2 +-
llvm/utils/DSAextract.py | 4 ++--
llvm/utils/add_argument_names.py | 2 +-
llvm/utils/convert-constraint-log-to-z3.py | 2 +-
llvm/utils/extract_vplan.py | 2 +-
llvm/utils/git/github-automation.py | 6 +++---
llvm/utils/indirect_calls.py | 2 +-
llvm/utils/relative_lines.py | 4 ++--
llvm/utils/update_test_prefix.py | 10 +++++-----
11 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/llvm/test/CodeGen/NVPTX/wmma.py b/llvm/test/CodeGen/NVPTX/wmma.py
index e1e46f0b8cab34..8f6378e3ce3cc1 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 c9c7db726f7652..2d32d66bbe3aee 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 1b833ff8932483..6937ca9e614f56 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 96f818bd2a8316..9787922e5f6742 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 2860dd4b90bcb5..af2f1297d9ee7f 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 a3c33f2ef45996..f96ac3106f68b4 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 cff6f5074d7716..96b9fd1b9a936b 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 da467f46b4dd31..ef6032c524c285 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 c18cffb26e7ae2..0c123cc143ab1a 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 86b190d5ea1824..d4c2d9d0429b90 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 434dc84fa4fc03..d11f2ae43abc43 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)
More information about the llvm-commits
mailing list