[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] fix(python): fix invalid escape sequences (PR #91856)

Eisuke Kawashima via lldb-commits lldb-commits at lists.llvm.org
Fri May 31 12:38:57 PDT 2024


https://github.com/e-kwsm updated https://github.com/llvm/llvm-project/pull/91856

>From 565cc84df335af91437bebd82626604033cc0f52 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(python): fix invalid escape sequences

---
 .github/workflows/version-check.py            |   2 +-
 .../clang-tidy/tool/clang-tidy-diff.py        |   4 +-
 .../checks/gen-static-analyzer-docs.py        |   2 +-
 clang/docs/tools/dump_ast_matchers.py         |  10 +-
 clang/test/Analysis/check-analyzer-fixit.py   |   2 +-
 .../lib/asan/scripts/asan_symbolize.py        |   4 +-
 .../dexter/dex/command/ParseCommand.py        |   4 +-
 cross-project-tests/lit.cfg.py                |   6 +-
 libcxx/test/libcxx/transitive_includes.gen.py |   2 +-
 libcxx/utils/generate_escaped_output_table.py |   2 +-
 .../utils/generate_width_estimation_table.py  |   2 +-
 lld/test/MachO/tools/validate-unwind-info.py  |   2 +-
 lld/utils/benchmark.py                        |   2 +-
 lldb/examples/python/crashlog.py              |   8 +-
 lldb/examples/python/delta.py                 |   2 +-
 lldb/examples/python/gdbremote.py             |   4 +-
 lldb/examples/python/jump.py                  |   6 +-
 lldb/examples/python/performance.py           |   2 +-
 lldb/examples/python/symbolication.py         |   6 +-
 .../Python/lldbsuite/test/lldbpexpect.py      |   2 +-
 .../test/test_runner/process_control.py       |   2 +-
 .../command/backticks/TestBackticksInAlias.py |   4 +-
 .../TestMemoryAllocSettings.py                |   2 +-
 .../API/commands/expression/test/TestExprs.py |   2 +-
 .../TestGuiExpandThreadsTree.py               |   2 +-
 lldb/test/API/commands/help/TestHelp.py       |   6 +-
 .../TestLaunchWithShellExpand.py              |   2 +-
 .../register/TestRegistersUnavailable.py      |   4 +-
 .../API/commands/settings/TestSettings.py     |  12 +-
 .../target/basic/TestTargetCommand.py         |   2 +-
 .../dwo/TestDumpDwo.py                        |  16 +-
 .../oso/TestDumpOso.py                        |  16 +-
 .../API/commands/trace/TestTraceDumpInfo.py   |   2 +-
 .../API/commands/trace/TestTraceEvents.py     |   4 +-
 .../API/commands/trace/TestTraceStartStop.py  |  12 +-
 lldb/test/API/commands/trace/TestTraceTSC.py  |  10 +-
 .../driver/quit_speed/TestQuitWithProcess.py  |   2 +-
 .../TestBreakpointByLineAndColumn.py          |   2 +-
 .../TestBreakpointLocations.py                |   2 +-
 .../TestDataFormatterAdv.py                   |   6 +-
 .../TestDataFormatterCpp.py                   |   6 +-
 .../TestDataFormatterObjCNSContainer.py       |  16 +-
 .../TestDataFormatterSkipSummary.py           |   2 +-
 .../TestDataFormatterGenericUnordered.py      |  22 +--
 .../libcxx/atomic/TestLibCxxAtomic.py         |   2 +-
 .../initializerlist/TestInitializerList.py    |   2 +-
 .../TestTypeSummaryListArg.py                 |   4 +-
 .../memory-region/TestMemoryRegion.py         |   2 +-
 .../target_var/TestTargetVar.py               |   2 +-
 .../completion/TestIOHandlerCompletion.py     |   2 +-
 .../c/function_types/TestFunctionTypes.py     |   2 +-
 .../TestRegisterVariables.py                  |   2 +-
 .../API/lang/c/set_values/TestSetValues.py    |   4 +-
 lldb/test/API/lang/c/strings/TestCStrings.py  |   2 +-
 .../API/lang/c/tls_globals/TestTlsGlobals.py  |   8 +-
 .../API/lang/cpp/char1632_t/TestChar1632T.py  |   8 +-
 .../cpp/class_static/TestStaticVariables.py   |   4 +-
 .../lang/cpp/class_types/TestClassTypes.py    |   2 +-
 .../cpp/dynamic-value/TestDynamicValue.py     |   2 +-
 .../API/lang/cpp/namespace/TestNamespace.py   |   4 +-
 .../lang/cpp/signed_types/TestSignedTypes.py  |   4 +-
 .../cpp/unsigned_types/TestUnsignedTypes.py   |   2 +-
 .../test/API/lang/mixed/TestMixedLanguages.py |   4 +-
 .../lang/objc/foundation/TestObjCMethods.py   |   2 +-
 .../objc/foundation/TestObjCMethodsNSArray.py |  10 +-
 .../objc/foundation/TestObjCMethodsNSError.py |   2 +-
 .../objc/foundation/TestObjCMethodsString.py  |  10 +-
 .../TestObjCDynamicValue.py                   |   2 +-
 .../TestObjCBuiltinTypes.py                   |   4 +-
 .../TestAArch64LinuxMTEMemoryTagCoreFile.py   |  44 ++---
 .../TestAArch64LinuxMTEMemoryTagAccess.py     | 160 +++++++++---------
 .../TestAArch64LinuxMTEMemoryTagFaults.py     |   6 +-
 .../TestAArch64LinuxTaggedMemoryRegion.py     |   4 +-
 .../macosx/add-dsym/TestAddDsymDownload.py    |   2 +-
 .../TestFirmwareCorefiles.py                  |   2 +-
 .../kern-ver-str/TestKernVerStrLCNOTE.py      |   2 +-
 .../TestMultipleBinaryCorefile.py             |   2 +-
 .../macosx/simulator/TestSimulatorPlatform.py |   2 +-
 .../skinny-corefile/TestSkinnyCorefile.py     |   2 +-
 .../TestTargetArchFromModule.py               |   2 +-
 .../API/source-manager/TestSourceManager.py   |   2 +-
 .../lldb-server/TestGdbRemoteModuleInfo.py    |   6 +-
 .../API/tools/lldb-server/TestPtyServer.py    |   2 +-
 .../TestGdbRemoteTargetXmlPacket.py           |   2 +-
 lldb/test/API/types/AbstractBase.py           |   6 +-
 lldb/utils/lui/sourcewin.py                   |   2 +-
 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_symbols.py                 |  20 +--
 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 +-
 mlir/utils/spirv/gen_spirv_dialect.py         |  10 +-
 polly/test/update_check.py                    |   4 +-
 100 files changed, 321 insertions(+), 321 deletions(-)

diff --git a/.github/workflows/version-check.py b/.github/workflows/version-check.py
index f75fd50300881..ed41ef4e1b16b 100755
--- a/.github/workflows/version-check.py
+++ b/.github/workflows/version-check.py
@@ -6,7 +6,7 @@
 
 
 def get_version_from_tag(tag):
-    m = re.match("llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$", tag)
+    m = re.match(r"llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$", tag)
     if m:
         if m.lastindex == 4:
             # We have an rc tag.
diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index d96b3450fdbe8..b048460abf2fc 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -242,7 +242,7 @@ def main():
     filename = None
     lines_by_file = {}
     for line in sys.stdin:
-        match = re.search('^\+\+\+\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, line)
+        match = re.search('^\\+\\+\\+\\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, line)
         if match:
             filename = match.group(2)
         if filename is None:
@@ -255,7 +255,7 @@ def main():
             if not re.match("^%s$" % args.iregex, filename, re.IGNORECASE):
                 continue
 
-        match = re.search("^@@.*\+(\d+)(,(\d+))?", line)
+        match = re.search(r"^@@.*\+(\d+)(,(\d+))?", line)
         if match:
             start_line = int(match.group(1))
             line_count = 1
diff --git a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
index 6545a3906fa50..c19a0d3de7f11 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
+++ b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
@@ -59,7 +59,7 @@ def get_checkers(checkers_td, checkers_rst):
             "clang-analyzer-" + checker_package_prefix + "." + checker_name
         )
         anchor_url = re.sub(
-            "\.", "-", checker_package_prefix + "." + checker_name
+            r"\.", "-", checker_package_prefix + "." + checker_name
         ).lower()
 
         if not hidden and "alpha" not in full_package_name.lower():
diff --git a/clang/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py
index 705ff0d4d4098..d47111819a1e2 100755
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -86,11 +86,11 @@ def extract_result_types(comment):
     parsed.
     """
     result_types = []
-    m = re.search(r"Usable as: Any Matcher[\s\n]*$", comment, re.S)
+    m = re.search("Usable as: Any Matcher[\\s\n]*$", comment, re.S)
     if m:
         return ["*"]
     while True:
-        m = re.match(r"^(.*)Matcher<([^>]+)>\s*,?[\s\n]*$", comment, re.S)
+        m = re.match("^(.*)Matcher<([^>]+)>\\s*,?[\\s\n]*$", comment, re.S)
         if not m:
             if re.search(r"Usable as:\s*$", comment):
                 return result_types
@@ -101,9 +101,9 @@ def extract_result_types(comment):
 
 
 def strip_doxygen(comment):
-    """Returns the given comment without \-escaped words."""
+    r"""Returns the given comment without \-escaped words."""
     # If there is only a doxygen keyword in the line, delete the whole line.
-    comment = re.sub(r"^\\[^\s]+\n", r"", comment, flags=re.M)
+    comment = re.sub("^\\\\[^\\s]+\n", r"", comment, flags=re.M)
 
     # If there is a doxygen \see command, change the \see prefix into "See also:".
     # FIXME: it would be better to turn this into a link to the target instead.
@@ -236,7 +236,7 @@ def act_on_decl(declaration, comment, allowed_types):
 
         # Parse the various matcher definition macros.
         m = re.match(
-            """.*AST_TYPE(LOC)?_TRAVERSE_MATCHER(?:_DECL)?\(
+            r""".*AST_TYPE(LOC)?_TRAVERSE_MATCHER(?:_DECL)?\(
                        \s*([^\s,]+\s*),
                        \s*(?:[^\s,]+\s*),
                        \s*AST_POLYMORPHIC_SUPPORTED_TYPES\(([^)]*)\)
diff --git a/clang/test/Analysis/check-analyzer-fixit.py b/clang/test/Analysis/check-analyzer-fixit.py
index b616255de89b0..43968f4b1b6e8 100644
--- a/clang/test/Analysis/check-analyzer-fixit.py
+++ b/clang/test/Analysis/check-analyzer-fixit.py
@@ -55,7 +55,7 @@ def run_test_once(args, extra_args):
     # themselves.  We need to keep the comments to preserve line numbers while
     # avoiding empty lines which could potentially trigger formatting-related
     # checks.
-    cleaned_test = re.sub("// *CHECK-[A-Z0-9\-]*:[^\r\n]*", "//", input_text)
+    cleaned_test = re.sub("// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", input_text)
     write_file(temp_file_name, cleaned_test)
 
     original_file_name = temp_file_name + ".orig"
diff --git a/compiler-rt/lib/asan/scripts/asan_symbolize.py b/compiler-rt/lib/asan/scripts/asan_symbolize.py
index b08769614aeb1..058a1614b55e6 100755
--- a/compiler-rt/lib/asan/scripts/asan_symbolize.py
+++ b/compiler-rt/lib/asan/scripts/asan_symbolize.py
@@ -316,7 +316,7 @@ def symbolize(self, addr, binary, offset):
         #   * For C functions atos omits parentheses and argument types.
         #   * For C++ functions the function name (i.e., `foo` above) may contain
         #     templates which may contain parentheses.
-        match = re.match("^(.*) \(in (.*)\) \((.*:\d*)\)$", atos_line)
+        match = re.match(r"^(.*) \(in (.*)\) \((.*:\d*)\)$", atos_line)
         logging.debug("atos_line: %s", atos_line)
         if match:
             function_name = match.group(1)
@@ -541,7 +541,7 @@ def process_line_posix(self, line):
         # names in the regex because it could be an
         # Objective-C or C++ demangled name.
         stack_trace_line_format = (
-            "^( *#([0-9]+) *)(0x[0-9a-f]+) *(?:in *.+)? *\((.*)\+(0x[0-9a-f]+)\)"
+            r"^( *#([0-9]+) *)(0x[0-9a-f]+) *(?:in *.+)? *\((.*)\+(0x[0-9a-f]+)\)"
         )
         match = re.match(stack_trace_line_format, line)
         if not match:
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py b/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
index 29d7867e80867..fa6647a0fd56d 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
@@ -128,7 +128,7 @@ def get_address_object(address_name: str, offset: int = 0):
 
 
 def _search_line_for_cmd_start(line: str, start: int, valid_commands: dict) -> int:
-    """Scan `line` for a string matching any key in `valid_commands`.
+    r"""Scan `line` for a string matching any key in `valid_commands`.
 
     Start searching from `start`.
     Commands escaped with `\` (E.g. `\DexLabel('a')`) are ignored.
@@ -543,7 +543,7 @@ def test_parse_share_line(self):
     def test_parse_escaped(self):
         """Escaped commands are ignored."""
 
-        lines = ['words \MockCmd("IGNORED") words words words\n']
+        lines = ['words \\MockCmd("IGNORED") words words words\n']
 
         values = self._find_all_mock_values_in_lines(lines)
 
diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py
index 774c4eaf4d976..c7d3217c99304 100644
--- a/cross-project-tests/lit.cfg.py
+++ b/cross-project-tests/lit.cfg.py
@@ -226,7 +226,7 @@ def can_target_host():
     xcode_lldb_vers = subprocess.check_output(["xcrun", "lldb", "--version"]).decode(
         "utf-8"
     )
-    match = re.search("lldb-(\d+)", xcode_lldb_vers)
+    match = re.search(r"lldb-(\d+)", xcode_lldb_vers)
     if match:
         apple_lldb_vers = int(match.group(1))
         if apple_lldb_vers < 1000:
@@ -250,7 +250,7 @@ def get_gdb_version_string():
     if len(gdb_vers_lines) < 1:
         print("Unkown GDB version format (too few lines)", file=sys.stderr)
         return None
-    match = re.search("GNU gdb \(.*?\) ((\d|\.)+)", gdb_vers_lines[0].strip())
+    match = re.search(r"GNU gdb \(.*?\) ((\d|\.)+)", gdb_vers_lines[0].strip())
     if match is None:
         print(f"Unkown GDB version format: {gdb_vers_lines[0]}", file=sys.stderr)
         return None
@@ -264,7 +264,7 @@ def get_clang_default_dwarf_version_string(triple):
     # Get the flags passed by the driver and look for -dwarf-version.
     cmd = f'{llvm_config.use_llvm_tool("clang")} -g -xc  -c - -v -### --target={triple}'
     stderr = subprocess.run(cmd.split(), stderr=subprocess.PIPE).stderr.decode()
-    match = re.search("-dwarf-version=(\d+)", stderr)
+    match = re.search(r"-dwarf-version=(\d+)", stderr)
     if match is None:
         print("Cannot determine default dwarf version", file=sys.stderr)
         return None
diff --git a/libcxx/test/libcxx/transitive_includes.gen.py b/libcxx/test/libcxx/transitive_includes.gen.py
index a67cab693b6e2..b5e91fb8ceb50 100644
--- a/libcxx/test/libcxx/transitive_includes.gen.py
+++ b/libcxx/test/libcxx/transitive_includes.gen.py
@@ -59,7 +59,7 @@
       continue
 
     # Escape slashes for the awk command below
-    escaped_header = header.replace('/', '\/')
+    escaped_header = header.replace('/', r'\/')
 
     print(f"""\
 //--- {header}.sh.cpp
diff --git a/libcxx/utils/generate_escaped_output_table.py b/libcxx/utils/generate_escaped_output_table.py
index 523a0be3a451d..9e7ea814ee221 100755
--- a/libcxx/utils/generate_escaped_output_table.py
+++ b/libcxx/utils/generate_escaped_output_table.py
@@ -84,7 +84,7 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
     return result
 
 
-DATA_ARRAY_TEMPLATE = """
+DATA_ARRAY_TEMPLATE = r"""
 /// The entries of the characters to escape in format's debug string.
 ///
 /// Contains the entries for [format.string.escaped]/2.2.1.2.1
diff --git a/libcxx/utils/generate_width_estimation_table.py b/libcxx/utils/generate_width_estimation_table.py
index 918dae25fe49e..b23b7378ac0c0 100644
--- a/libcxx/utils/generate_width_estimation_table.py
+++ b/libcxx/utils/generate_width_estimation_table.py
@@ -99,7 +99,7 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
     return result
 
 
-DATA_ARRAY_TEMPLATE = """
+DATA_ARRAY_TEMPLATE = r"""
 /// The entries of the characters with an estimated width of 2.
 ///
 /// Contains the entries for [format.string.std]/12
diff --git a/lld/test/MachO/tools/validate-unwind-info.py b/lld/test/MachO/tools/validate-unwind-info.py
index ac49f1ecb5889..1cc82f8279273 100755
--- a/lld/test/MachO/tools/validate-unwind-info.py
+++ b/lld/test/MachO/tools/validate-unwind-info.py
@@ -11,7 +11,7 @@
 
 
 def main():
-    hex = "[a-f\d]"
+    hex = r"[a-f\d]"
     hex8 = hex + "{8}"
 
     parser = argparse.ArgumentParser(description=__doc__)
diff --git a/lld/utils/benchmark.py b/lld/utils/benchmark.py
index a07d5ecc69417..7202e07ec438d 100755
--- a/lld/utils/benchmark.py
+++ b/lld/utils/benchmark.py
@@ -51,7 +51,7 @@ def __str__(self):
 def getBenchmarks():
     ret = []
     for i in glob.glob("*/response*.txt"):
-        m = re.match("response-(.*)\.txt", os.path.basename(i))
+        m = re.match(r"response-(.*)\.txt", os.path.basename(i))
         variant = m.groups()[0] if m else None
         ret.append(Bench(os.path.dirname(i), variant))
     return ret
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 641b2e64d53b1..13e5d77ec6fe2 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -294,7 +294,7 @@ class DarwinImage(symbolication.Image):
             except:
                 dsymForUUIDBinary = ""
 
-        dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
+        dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
 
         def __init__(
             self, text_addr_lo, text_addr_hi, identifier, version, uuid, path, verbose
@@ -499,7 +499,7 @@ def find_image_with_identifier(self, identifier):
         for image in self.images:
             if image.identifier == identifier:
                 return image
-        regex_text = "^.*\.%s$" % (re.escape(identifier))
+        regex_text = r"^.*\.%s$" % (re.escape(identifier))
         regex = re.compile(regex_text)
         for image in self.images:
             if regex.match(image.identifier):
@@ -919,7 +919,7 @@ def get(cls):
             version = r"(?:" + super().version + r"\s+)?"
             address = r"(0x[0-9a-fA-F]{4,})"  # 4 digits or more
 
-            symbol = """
+            symbol = r"""
                         (?:
                             [ ]+
                             (?P<symbol>.+)
@@ -1089,7 +1089,7 @@ def parse_normal(self, line):
             self.crashlog.process_identifier = line[11:].strip()
         elif line.startswith("Version:"):
             version_string = line[8:].strip()
-            matched_pair = re.search("(.+)\((.+)\)", version_string)
+            matched_pair = re.search(r"(.+)\((.+)\)", version_string)
             if matched_pair:
                 self.crashlog.process_version = matched_pair.group(1)
                 self.crashlog.process_compatability_version = matched_pair.group(2)
diff --git a/lldb/examples/python/delta.py b/lldb/examples/python/delta.py
index eeb3c177cfa90..f847b95ab119f 100755
--- a/lldb/examples/python/delta.py
+++ b/lldb/examples/python/delta.py
@@ -99,7 +99,7 @@ def parse_log_file(file, options):
     print("# Log file: '%s'" % file)
     print("#----------------------------------------------------------------------")
 
-    timestamp_regex = re.compile("(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
+    timestamp_regex = re.compile(r"(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
 
     base_time = 0.0
     last_time = 0.0
diff --git a/lldb/examples/python/gdbremote.py b/lldb/examples/python/gdbremote.py
index 40ee15853fdb2..0bbfc1a0f1eed 100755
--- a/lldb/examples/python/gdbremote.py
+++ b/lldb/examples/python/gdbremote.py
@@ -1537,12 +1537,12 @@ def parse_gdb_log(file, options):
     a long time during a preset set of debugger commands."""
 
     tricky_commands = ["qRegisterInfo"]
-    timestamp_regex = re.compile("(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
+    timestamp_regex = re.compile(r"(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
     packet_name_regex = re.compile("([A-Za-z_]+)[^a-z]")
     packet_transmit_name_regex = re.compile(
         "(?P<direction>send|read) packet: (?P<packet>.*)"
     )
-    packet_contents_name_regex = re.compile("\$([^#]*)#[0-9a-fA-F]{2}")
+    packet_contents_name_regex = re.compile(r"\$([^#]*)#[0-9a-fA-F]{2}")
     packet_checksum_regex = re.compile(".*#[0-9a-fA-F]{2}$")
     packet_names_regex_str = "(" + "|".join(gdb_remote_commands.keys()) + ")(.*)"
     packet_names_regex = re.compile(packet_names_regex_str)
diff --git a/lldb/examples/python/jump.py b/lldb/examples/python/jump.py
index e086df5fd1528..8d52bd9af43f6 100644
--- a/lldb/examples/python/jump.py
+++ b/lldb/examples/python/jump.py
@@ -38,7 +38,7 @@ def parse_linespec(linespec, frame, result):
             )
 
     if not matched:
-        mo = re.match("^\+([0-9]+)$", linespec)
+        mo = re.match(r"^\+([0-9]+)$", linespec)
         if mo is not None:
             matched = True
             # print "Matched +<count>"
@@ -54,7 +54,7 @@ def parse_linespec(linespec, frame, result):
             )
 
     if not matched:
-        mo = re.match("^\-([0-9]+)$", linespec)
+        mo = re.match(r"^\-([0-9]+)$", linespec)
         if mo is not None:
             matched = True
             # print "Matched -<count>"
@@ -79,7 +79,7 @@ def parse_linespec(linespec, frame, result):
             breakpoint = target.BreakpointCreateByLocation(file_name, line_number)
 
     if not matched:
-        mo = re.match("\*((0x)?([0-9a-f]+))$", linespec)
+        mo = re.match(r"\*((0x)?([0-9a-f]+))$", linespec)
         if mo is not None:
             matched = True
             # print "Matched <address-expression>"
diff --git a/lldb/examples/python/performance.py b/lldb/examples/python/performance.py
index 869a0b061cf85..b86b5a52522e0 100755
--- a/lldb/examples/python/performance.py
+++ b/lldb/examples/python/performance.py
@@ -346,7 +346,7 @@ def __init__(self, pid):
 
     def Measure(self):
         output = subprocess.getoutput(self.command).split("\n")[-1]
-        values = re.split("[-+\s]+", output)
+        values = re.split(r"[-+\s]+", output)
         for idx, stat in enumerate(values):
             multiplier = 1
             if stat:
diff --git a/lldb/examples/python/symbolication.py b/lldb/examples/python/symbolication.py
index f6dcc8b9a7943..b16745ee963c9 100755
--- a/lldb/examples/python/symbolication.py
+++ b/lldb/examples/python/symbolication.py
@@ -177,9 +177,9 @@ class Section:
     """Class that represents an load address range"""
 
     sect_info_regex = re.compile("(?P<name>[^=]+)=(?P<range>.*)")
-    addr_regex = re.compile("^\s*(?P<start>0x[0-9A-Fa-f]+)\s*$")
+    addr_regex = re.compile(r"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*$")
     range_regex = re.compile(
-        "^\s*(?P<start>0x[0-9A-Fa-f]+)\s*(?P<op>[-+])\s*(?P<end>0x[0-9A-Fa-f]+)\s*$"
+        r"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*(?P<op>[-+])\s*(?P<end>0x[0-9A-Fa-f]+)\s*$"
     )
 
     def __init__(self, start_addr=None, end_addr=None, name=None):
@@ -557,7 +557,7 @@ def find_images_with_identifier(self, identifier):
             if image.identifier == identifier:
                 images.append(image)
         if len(images) == 0:
-            regex_text = "^.*\.%s$" % (re.escape(identifier))
+            regex_text = r"^.*\.%s$" % (re.escape(identifier))
             regex = re.compile(regex_text)
             for image in self.images:
                 if regex.match(image.identifier):
diff --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
index 998a080565b6b..3279e1fd39f8c 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -104,4 +104,4 @@ def cursor_forward_escape_seq(self, chars_to_move):
         Returns the escape sequence to move the cursor forward/right
         by a certain amount of characters.
         """
-        return b"\x1b\[" + str(chars_to_move).encode("utf-8") + b"C"
+        return b"\x1b\\[" + str(chars_to_move).encode("utf-8") + b"C"
diff --git a/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py b/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
index 07c17993bc878..8ab219a92d99d 100644
--- a/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
+++ b/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
@@ -91,7 +91,7 @@ def timeout_to_seconds(timeout):
 
 
 class ProcessHelper(object):
-    """Provides an interface for accessing process-related functionality.
+    r"""Provides an interface for accessing process-related functionality.
 
     This class provides a factory method that gives the caller a
     platform-specific implementation instance of the class.
diff --git a/lldb/test/API/commands/command/backticks/TestBackticksInAlias.py b/lldb/test/API/commands/command/backticks/TestBackticksInAlias.py
index c31a08ac00182..2cb8d225d6d07 100644
--- a/lldb/test/API/commands/command/backticks/TestBackticksInAlias.py
+++ b/lldb/test/API/commands/command/backticks/TestBackticksInAlias.py
@@ -20,7 +20,7 @@ def test_backticks_in_alias(self):
         interp = self.dbg.GetCommandInterpreter()
         result = lldb.SBCommandReturnObject()
         interp.HandleCommand(
-            "command alias _test-argv-cmd expression -Z \`argc\` -- argv", result
+            r"command alias _test-argv-cmd expression -Z \`argc\` -- argv", result
         )
         self.assertCommandReturn(result, "Made the alias")
         interp.HandleCommand("_test-argv-cmd", result)
@@ -28,7 +28,7 @@ def test_backticks_in_alias(self):
 
         # Now try a harder case where we create this using an alias:
         interp.HandleCommand(
-            "command alias _test-argv-parray-cmd parray \`argc\` argv", result
+            r"command alias _test-argv-parray-cmd parray \`argc\` argv", result
         )
         self.assertCommandReturn(result, "Made the alias")
         interp.HandleCommand("_test-argv-parray-cmd", result)
diff --git a/lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py b/lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
index d27f07717affb..a82141a0792f2 100644
--- a/lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
+++ b/lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
@@ -30,7 +30,7 @@ def test(self):
         alloc0 = re.search("^.*IRMemoryMap::Malloc.+?0xdead0000.*$", log, re.MULTILINE)
         # Malloc adds additional bytes to allocation size, hence 10007
         alloc1 = re.search(
-            "^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$", log, re.MULTILINE
+            r"^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$", log, re.MULTILINE
         )
         self.assertTrue(alloc0, "Couldn't find an allocation at a given address.")
         self.assertTrue(
diff --git a/lldb/test/API/commands/expression/test/TestExprs.py b/lldb/test/API/commands/expression/test/TestExprs.py
index 41faf07f8cb44..17fd952130ee7 100644
--- a/lldb/test/API/commands/expression/test/TestExprs.py
+++ b/lldb/test/API/commands/expression/test/TestExprs.py
@@ -50,7 +50,7 @@ def build_and_run(self):
     def test_floating_point_expr_commands(self):
         self.build_and_run()
 
-        self.expect("expression 2.234f", patterns=["\(float\) \$.* = 2\.234"])
+        self.expect("expression 2.234f", patterns=[r"\(float\) \$.* = 2\.234"])
         # (float) $2 = 2.234
 
     def test_many_expr_commands(self):
diff --git a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
index 3bb45521747d8..69aa674f6ae5d 100644
--- a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
+++ b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
@@ -48,7 +48,7 @@ def test_gui(self):
         self.child.expect_exact("Threads")
 
         # The main thread should be expanded.
-        self.child.expect("#\d+: main")
+        self.child.expect(r"#\d+: main")
 
         # Quit the GUI
         self.child.send(escape_key)
diff --git a/lldb/test/API/commands/help/TestHelp.py b/lldb/test/API/commands/help/TestHelp.py
index f0f5bcb321801..6aaff17fa4ea6 100644
--- a/lldb/test/API/commands/help/TestHelp.py
+++ b/lldb/test/API/commands/help/TestHelp.py
@@ -349,13 +349,13 @@ def test_help_show_tags(self):
         self.expect(
             "help memory read",
             patterns=[
-                "--show-tags\n\s+Include memory tags in output "
-                "\(does not apply to binary output\)."
+                "--show-tags\n\\s+Include memory tags in output "
+                "\\(does not apply to binary output\\)."
             ],
         )
         self.expect(
             "help memory find",
-            patterns=["--show-tags\n\s+Include memory tags in output."],
+            patterns=["--show-tags\n\\s+Include memory tags in output."],
         )
 
     @no_debug_info_test
diff --git a/lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py b/lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
index fcf61c9775c63..a7f8b38649b22 100644
--- a/lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
+++ b/lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
@@ -93,7 +93,7 @@ def test(self):
 
         self.runCmd("process kill")
 
-        self.runCmd("process launch -X true -w %s -- foo\ bar" % (self.getBuildDir()))
+        self.runCmd(r"process launch -X true -w %s -- foo\ bar" % (self.getBuildDir()))
 
         process = self.process()
 
diff --git a/lldb/test/API/commands/register/register/TestRegistersUnavailable.py b/lldb/test/API/commands/register/register/TestRegistersUnavailable.py
index abd3aeace8969..0ccccd2f09712 100644
--- a/lldb/test/API/commands/register/register/TestRegistersUnavailable.py
+++ b/lldb/test/API/commands/register/register/TestRegistersUnavailable.py
@@ -48,12 +48,12 @@ def test_unavailable_registers(self):
             "register read --all",
             patterns=[
                 "(?sm)^general purpose registers:\n"
-                "^\s+rdx = 0x5555555555555555\n"
+                "^\\s+rdx = 0x5555555555555555\n"
                 ".*"
                 "^3 registers were unavailable.\n"
                 "\n"
                 "^supplementary registers:\n"
-                "^\s+edx = 0x55555555\n"
+                "^\\s+edx = 0x55555555\n"
                 ".*"
                 "^12 registers were unavailable."
             ],
diff --git a/lldb/test/API/commands/settings/TestSettings.py b/lldb/test/API/commands/settings/TestSettings.py
index 385acceb7a8b5..52348bf52507a 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -186,13 +186,13 @@ def cleanup():
         self.addTearDownHook(cleanup)
 
         self.runCmd("settings show frame-format")
-        m = re.match('^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
+        m = re.match(r'^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
         self.assertTrue(m, "Bad settings string")
         self.format_string = m.group(1)
 
         # Change the default format to print function.name rather than
         # function.name-with-args
-        format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n"
+        format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\\`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n"
         self.runCmd("settings set frame-format %s" % format_string)
 
         # Immediately test the setting.
@@ -671,7 +671,7 @@ def test_settings_with_trailing_whitespace(self):
         )
         self.runCmd("settings set target.run-args 1 2 3")  # Set to known value
         # Set to new value with trailing whitespaces
-        self.runCmd("settings set target.run-args 3 \  \ ")
+        self.runCmd(r"settings set target.run-args 3 \  \ ")
         self.expect(
             "settings show target.run-args",
             SETTING_MSG("target.run-args"),
@@ -793,11 +793,11 @@ def test_settings_clear_all(self):
         # Check that settings have their default values after clearing.
         self.expect(
             "settings show target.env-vars",
-            patterns=["^target.env-vars \(dictionary of strings\) =\s*$"],
+            patterns=[r"^target.env-vars \(dictionary of strings\) =\s*$"],
         )
         self.expect(
             "settings show target.run-args",
-            patterns=["^target.run-args \(arguments\) =\s*$"],
+            patterns=[r"^target.run-args \(arguments\) =\s*$"],
         )
         self.expect("settings show auto-confirm", substrs=["false"])
         self.expect("settings show tab-size", substrs=["2"])
@@ -894,7 +894,7 @@ def test_experimental_settings(self):
         # showing & setting an undefined .experimental. setting should generate no errors.
         self.expect(
             "settings show target.experimental.setting-which-does-not-exist",
-            patterns=["^\s$"],
+            patterns=[r"^\s$"],
             error=False,
         )
         self.expect(
diff --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index cb7a5f33f6643..f7601700d790f 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -74,7 +74,7 @@ def do_target_command(self):
             # Find the largest index of the existing list.
             import re
 
-            pattern = re.compile("target #(\d+):")
+            pattern = re.compile(r"target #(\d+):")
             for line in reversed(output.split(os.linesep)):
                 match = pattern.search(line)
                 if match:
diff --git a/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py b/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py
index 05c72945b1439..13d12e3686a17 100644
--- a/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py
+++ b/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py
@@ -94,11 +94,11 @@ def test_dwos_loaded_table_output(self):
         self.expect(
             "target modules dump separate-debug-info",
             patterns=[
-                "Symbol file: .*?a\.out",
+                r"Symbol file: .*?a\.out",
                 'Type: "dwo"',
-                "Dwo ID\s+Err\s+Dwo Path",
-                "0x[a-zA-Z0-9]{16}\s+.*main\.dwo",
-                "0x[a-zA-Z0-9]{16}\s+.*foo\.dwo",
+                r"Dwo ID\s+Err\s+Dwo Path",
+                r"0x[a-zA-Z0-9]{16}\s+.*main\.dwo",
+                r"0x[a-zA-Z0-9]{16}\s+.*foo\.dwo",
             ],
         )
 
@@ -118,11 +118,11 @@ def test_dwos_not_loaded_table_output(self):
         self.expect(
             "target modules dump separate-debug-info",
             patterns=[
-                "Symbol file: .*?a\.out",
+                r"Symbol file: .*?a\.out",
                 'Type: "dwo"',
-                "Dwo ID\s+Err\s+Dwo Path",
-                "0x[a-zA-Z0-9]{16}\s+E\s+.*main\.dwo",
-                "0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.dwo",
+                r"Dwo ID\s+Err\s+Dwo Path",
+                r"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.dwo",
+                r"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.dwo",
             ],
         )
 
diff --git a/lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py b/lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py
index 06dc823459184..4e7560338b1d4 100644
--- a/lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py
+++ b/lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py
@@ -93,11 +93,11 @@ def test_shows_oso_loaded_table_output(self):
         self.expect(
             "target modules dump separate-debug-info",
             patterns=[
-                "Symbol file: .*?a\.out",
+                r"Symbol file: .*?a\.out",
                 'Type: "oso"',
-                "Mod Time\s+Err\s+Oso Path",
-                "0x[a-zA-Z0-9]{16}\s+.*main\.o",
-                "0x[a-zA-Z0-9]{16}\s+.*foo\.o",
+                r"Mod Time\s+Err\s+Oso Path",
+                r"0x[a-zA-Z0-9]{16}\s+.*main\.o",
+                r"0x[a-zA-Z0-9]{16}\s+.*foo\.o",
             ],
         )
 
@@ -119,11 +119,11 @@ def test_shows_oso_not_loaded_table_output(self):
         self.expect(
             "target modules dump separate-debug-info",
             patterns=[
-                "Symbol file: .*?a\.out",
+                r"Symbol file: .*?a\.out",
                 'Type: "oso"',
-                "Mod Time\s+Err\s+Oso Path",
-                "0x[a-zA-Z0-9]{16}\s+E\s+.*main\.o",
-                "0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.o",
+                r"Mod Time\s+Err\s+Oso Path",
+                r"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.o",
+                r"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.o",
             ],
         )
 
diff --git a/lldb/test/API/commands/trace/TestTraceDumpInfo.py b/lldb/test/API/commands/trace/TestTraceDumpInfo.py
index 3f67475d631dd..52449631f6aa9 100644
--- a/lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ b/lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -64,7 +64,7 @@ def testDumpRawTraceSize(self):
       hardware disabled tracing: 4
       trace synchronization point: 1""",
             ],
-            patterns=["Decoding instructions: \d.\d\ds"],
+            patterns=[r"Decoding instructions: \d.\d\ds"],
         )
 
     def testDumpRawTraceSizeJSON(self):
diff --git a/lldb/test/API/commands/trace/TestTraceEvents.py b/lldb/test/API/commands/trace/TestTraceEvents.py
index 52f6241456b76..c42b1a7fc01bd 100644
--- a/lldb/test/API/commands/trace/TestTraceEvents.py
+++ b/lldb/test/API/commands/trace/TestTraceEvents.py
@@ -68,7 +68,7 @@ def testPauseEvents(self):
         self.expect(
             "thread trace dump instructions -e -f",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
     0: \(event\) trace synchronization point \[offset \= 0x0xec0\]
     1: \(event\) hardware disabled tracing
   a.out`main \+ 23 at main.cpp:12
@@ -102,7 +102,7 @@ def testPauseEvents(self):
         self.expect(
             "thread trace dump instructions -e --id 18",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
   a.out`symbol stub for: foo\(\)
     18: {ADDRESS_REGEX}    jmpq .*
     17: \(event\) software disabled tracing
diff --git a/lldb/test/API/commands/trace/TestTraceStartStop.py b/lldb/test/API/commands/trace/TestTraceStartStop.py
index 134cf13096edb..9ccb51e4b6ef6 100644
--- a/lldb/test/API/commands/trace/TestTraceStartStop.py
+++ b/lldb/test/API/commands/trace/TestTraceStartStop.py
@@ -244,7 +244,7 @@ def testStartStopLiveThreads(self):
         self.expect(
             "thread trace dump instructions -f",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
   a.out`main \+ 4 at main.cpp:2
     2: {ADDRESS_REGEX}    movl"""
             ],
@@ -255,7 +255,7 @@ def testStartStopLiveThreads(self):
         self.expect(
             "thread trace dump instructions -f",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
   a.out`main \+ 4 at main.cpp:2
     2: {ADDRESS_REGEX}    movl .*
   a.out`main \+ 11 at main.cpp:4
@@ -269,7 +269,7 @@ def testStartStopLiveThreads(self):
         self.expect(
             "thread trace dump instructions",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
   a.out`main \+ 32 at main.cpp:4
     10: {ADDRESS_REGEX}    jle  .* ; <\+20> at main.cpp:5
     8: {ADDRESS_REGEX}    cmpl .*
@@ -297,7 +297,7 @@ def testStartStopLiveThreads(self):
         self.expect(
             "thread trace dump instructions -f",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
   a.out`main \+ 20 at main.cpp:5
     2: {ADDRESS_REGEX}    xorl"""
             ],
@@ -306,7 +306,7 @@ def testStartStopLiveThreads(self):
         self.expect(
             "thread trace dump instructions",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
   a.out`main \+ 20 at main.cpp:5
     2: {ADDRESS_REGEX}    xorl"""
             ],
@@ -336,7 +336,7 @@ def testStartStopLiveThreads(self):
         self.expect(
             "thread trace dump instructions -c 1",
             patterns=[
-                f"""thread #1: tid = .*
+                fr"""thread #1: tid = .*
   a.out`main \+ 11 at main.cpp:4"""
             ],
         )
diff --git a/lldb/test/API/commands/trace/TestTraceTSC.py b/lldb/test/API/commands/trace/TestTraceTSC.py
index 580cb347dc30a..4a19065e60c2b 100644
--- a/lldb/test/API/commands/trace/TestTraceTSC.py
+++ b/lldb/test/API/commands/trace/TestTraceTSC.py
@@ -20,7 +20,7 @@ def testTscPerThread(self):
         self.expect("n")
         self.expect(
             "thread trace dump instructions -t -c 1",
-            patterns=[": \[\d+.\d+ ns\] 0x0000000000400511    movl"],
+            patterns=[r": \[\d+.\d+ ns\] 0x0000000000400511    movl"],
         )
 
     @testSBAPIAndCommands
@@ -43,7 +43,7 @@ def testMultipleTscsPerThread(self):
         self.runCmd("thread trace dump instructions -t --raw --forward")
         id_to_timestamp = {}
         for line in self.res.GetOutput().splitlines():
-            m = re.search("    (.+): \[(.+)\ ns].*", line)
+            m = re.search(r"    (.+): \[(.+)\ ns].*", line)
             if m:
                 id_to_timestamp[int(m.group(1))] = m.group(2)
         self.assertEqual(len(id_to_timestamp), 3)
@@ -69,12 +69,12 @@ def testTscPerProcess(self):
         self.expect("n")
         self.expect(
             "thread trace dump instructions -t -c 1",
-            patterns=[": \[\d+.\d+ ns\] 0x0000000000400511    movl"],
+            patterns=[r": \[\d+.\d+ ns\] 0x0000000000400511    movl"],
         )
 
         self.expect(
             "thread trace dump instructions -t -c 1 --pretty-json",
-            patterns=['''"timestamp_ns": "\d+.\d+"'''],
+            patterns=[r'''"timestamp_ns": "\d+.\d+"'''],
         )
 
     @testSBAPIAndCommands
@@ -91,7 +91,7 @@ def testDumpingAfterTracingWithoutTsc(self):
         self.expect("n")
         self.expect(
             "thread trace dump instructions -t -c 1",
-            patterns=[": \[unavailable\] 0x0000000000400511    movl"],
+            patterns=[r": \[unavailable\] 0x0000000000400511    movl"],
         )
 
         self.expect(
diff --git a/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py b/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py
index 5cfcf5d69fd2a..2412b295bfb59 100644
--- a/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py
+++ b/lldb/test/API/driver/quit_speed/TestQuitWithProcess.py
@@ -28,7 +28,7 @@ def test_run_quit(self):
         # Launch the process without a TTY so we don't have to interrupt:
         child.sendline("process launch -n")
         print("launched process")
-        child.expect("Process ([\d]*) launched:")
+        child.expect(r"Process ([\d]*) launched:")
         print("Got launch message")
         child.sendline("quit")
         print("sent quit")
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py b/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
index fe99adf425513..5798c8ffa8220 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
@@ -60,7 +60,7 @@ def testBreakpointByLineAndColumnNearestCode(self):
 
         for pattern in patterns:
             line = line_number("main.cpp", pattern) + 1
-            column = int(re.search("\(col:([0-9]+)\)", pattern).group(1))
+            column = int(re.search(r"\(col:([0-9]+)\)", pattern).group(1))
             source_loc.append({"line": line, "column": column})
 
         target = self.createTestTarget()
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py b/lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
index d87e6275f7b51..e0c93e3c18581 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
@@ -53,7 +53,7 @@ def set_breakpoint(self):
             ],
             patterns=[
                 "where = a.out`func_inlined .+unresolved, hit count = 0",
-                "where = a.out`main .+\[inlined\].+unresolved, hit count = 0",
+                r"where = a.out`main .+\[inlined\].+unresolved, hit count = 0",
             ],
         )
 
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
index b740689e67538..cc7ac3dda97cc 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -104,7 +104,7 @@ def cleanup():
 
         self.runCmd("type summary clear")
 
-        self.runCmd('type summary add --summary-string "${var[0-1]}" -x "int\[[0-9]\]"')
+        self.runCmd(r'type summary add --summary-string "${var[0-1]}" -x "int\[[0-9]\]"')
 
         self.expect("frame variable int_array", substrs=["1,2"])
 
@@ -119,7 +119,7 @@ def cleanup():
 
         self.runCmd("type summary clear")
 
-        self.runCmd('type summary add -c -x "i_am_cool\[[0-9]\]"')
+        self.runCmd(r'type summary add -c -x "i_am_cool\[[0-9]\]"')
         self.runCmd("type summary add -c i_am_cool")
 
         self.expect(
@@ -172,7 +172,7 @@ def cleanup():
         self.runCmd("type summary clear")
 
         self.runCmd(
-            'type summary add --summary-string "${*var[].x[0-3]%hex} is a bitfield on a set of integers" -x "SimpleWithPointers\[[0-9]\]"'
+            r'type summary add --summary-string "${*var[].x[0-3]%hex} is a bitfield on a set of integers" -x "SimpleWithPointers\[[0-9]\]"'
         )
 
         self.expect(
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
index 6fa15d9e5ee60..370781fd4f5e0 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -62,7 +62,7 @@ def cleanup():
         self.expect(
             "frame variable",
             patterns=[
-                "\(Speed\) SPILookHex = 0x[0-9a-f]+"  # Speed should look hex-ish now.
+                r"\(Speed\) SPILookHex = 0x[0-9a-f]+"  # Speed should look hex-ish now.
             ],
         )
 
@@ -71,14 +71,14 @@ def cleanup():
             self.expect(
                 "frame variable",
                 patterns=[
-                    "\(SignalMask\) SMILookHex = 0x[0-9a-f]+"  # SignalMask should look hex-ish now.
+                    r"\(SignalMask\) SMILookHex = 0x[0-9a-f]+"  # SignalMask should look hex-ish now.
                 ],
             )
             self.expect(
                 "frame variable",
                 matching=False,
                 patterns=[
-                    "\(Type4\) T4ILookChar = 0x[0-9a-f]+"  # Type4 should NOT look hex-ish now.
+                    r"\(Type4\) T4ILookChar = 0x[0-9a-f]+"  # Type4 should NOT look hex-ish now.
                 ],
             )
 
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
index 4046dc79538a5..c90a5c61d9c0b 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
@@ -53,7 +53,7 @@ def nscontainers_data_formatter_commands(self):
         self.expect(
             "frame variable -d run-target *nscfDictionary",
             patterns=[
-                "\(__NSCFDictionary\) \*nscfDictionary =",
+                r"\(__NSCFDictionary\) \*nscfDictionary =",
                 'key = 0x.* @"foo"',
                 'value = 0x.* @"foo"',
                 'key = 0x.* @"bar"',
@@ -68,7 +68,7 @@ def nscontainers_data_formatter_commands(self):
         self.expect(
             "frame variable -d run-target *cfDictionaryRef",
             patterns=[
-                "\(const __CFDictionary\) \*cfDictionaryRef =",
+                r"\(const __CFDictionary\) \*cfDictionaryRef =",
                 'key = 0x.* @"foo"',
                 'value = 0x.* @"foo"',
                 'key = 0x.* @"bar"',
@@ -89,18 +89,18 @@ def nscontainers_data_formatter_commands(self):
         self.expect(
             "frame variable -d run-target *nscfSet",
             patterns=[
-                "\(__NSCFSet\) \*nscfSet =",
-                '\[0\] = 0x.* @".*"',
-                '\[1\] = 0x.* @".*"',
+                r"\(__NSCFSet\) \*nscfSet =",
+                r'\[0\] = 0x.* @".*"',
+                r'\[1\] = 0x.* @".*"',
             ],
         )
 
         self.expect(
             "frame variable -d run-target *cfSetRef",
             patterns=[
-                "\(const __CFSet\) \*cfSetRef =",
-                '\[0\] = 0x.* @".*"',
-                '\[1\] = 0x.* @".*"',
+                r"\(const __CFSet\) \*cfSetRef =",
+                r'\[0\] = 0x.* @".*"',
+                r'\[1\] = 0x.* @".*"',
             ],
         )
 
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py b/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
index aac18e13bf54f..460de8a4563f0 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
@@ -167,7 +167,7 @@ def cleanup():
             gcc_version_output = system([[lldbutil.which(self.getCompiler()), "-v"]])
             self.trace("my output:", gcc_version_output)
             for line in gcc_version_output.split(os.linesep):
-                m = re.search("\(Apple Inc\. build ([0-9]+)\)", line)
+                m = re.search(r"\(Apple Inc\. build ([0-9]+)\)", line)
                 self.trace("line:", line)
                 if m:
                     gcc_build = int(m.group(1))
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
index 59c24bcead4a4..e6fc7e0e117a7 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -83,9 +83,9 @@ def cleanup():
             [
                 "%s::unordered_set" % ns,
                 "size=5 {",
-                "\[\d\] = 5",
-                "\[\d\] = 3",
-                "\[\d\] = 2",
+                r"\[\d\] = 5",
+                r"\[\d\] = 3",
+                r"\[\d\] = 2",
             ],
         )
 
@@ -94,9 +94,9 @@ def cleanup():
             [
                 "%s::unordered_set" % ns,
                 "size=5 {",
-                '\[\d\] = "is"',
-                '\[\d\] = "world"',
-                '\[\d\] = "hello"',
+                r'\[\d\] = "is"',
+                r'\[\d\] = "world"',
+                r'\[\d\] = "hello"',
             ],
         )
 
@@ -105,9 +105,9 @@ def cleanup():
             [
                 "%s::unordered_multiset" % ns,
                 "size=6 {",
-                "(\[\d\] = 3(\\n|.)+){3}",
-                "\[\d\] = 2",
-                "\[\d\] = 1",
+                "(\\[\\d\\] = 3(\\n|.)+){3}",
+                r"\[\d\] = 2",
+                r"\[\d\] = 1",
             ],
         )
 
@@ -116,8 +116,8 @@ def cleanup():
             [
                 "%s::unordered_multiset" % ns,
                 "size=5 {",
-                '(\[\d\] = "is"(\\n|.)+){2}',
-                '(\[\d\] = "world"(\\n|.)+){2}',
+                '(\\[\\d\\] = "is"(\\n|.)+){2}',
+                '(\\[\\d\\] = "world"(\\n|.)+){2}',
             ],
         )
 
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
index 241226d50df80..2d1131d99c5f3 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
@@ -31,7 +31,7 @@ def test(self):
         self.runCmd("run", RUN_SUCCEEDED)
 
         lldbutil.skip_if_library_missing(
-            self, self.target(), lldbutil.PrintableRegex("libc\+\+")
+            self, self.target(), lldbutil.PrintableRegex(r"libc\+\+")
         )
 
         # The stop reason of the thread should be breakpoint.
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
index 0919eb3c5dd81..0f2c24baafbda 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
@@ -25,7 +25,7 @@ def test(self):
         self.runCmd("run", RUN_SUCCEEDED)
 
         lldbutil.skip_if_library_missing(
-            self, self.target(), lldbutil.PrintableRegex("libc\+\+")
+            self, self.target(), lldbutil.PrintableRegex(r"libc\+\+")
         )
 
         # The stop reason of the thread should be breakpoint.
diff --git a/lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py b/lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
index 0bc34910df7d2..6b883a5bb6c8f 100644
--- a/lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
+++ b/lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
@@ -17,7 +17,7 @@ def test_type_summary_list_with_arg(self):
             "type summary list Foo", substrs=["Category: default", "Category: system"]
         )
         self.expect(
-            "type summary list char", substrs=["char ?(\*|\[\])", "char ?\[[0-9]+\]"]
+            "type summary list char", substrs=[r"char ?(\*|\[\])", r"char ?\[[0-9]+\]"]
         )
 
         self.expect("type summary list -w default", substrs=["system"], matching=False)
@@ -28,6 +28,6 @@ def test_type_summary_list_with_arg(self):
         )
         self.expect(
             "type summary list -w system char",
-            substrs=["char ?(\*|\[\])", "char ?\[[0-9]+\]"],
+            substrs=[r"char ?(\*|\[\])", r"char ?\[[0-9]+\]"],
             matching=True,
         )
diff --git a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
index 577411ebc1037..50182e72e498c 100644
--- a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
+++ b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
@@ -95,7 +95,7 @@ def test_command(self):
         self.assertFalse(result.Succeeded())
         self.assertRegex(
             result.GetError(),
-            "Usage: memory region <address\-expression> \(or \-\-all\)",
+            r"Usage: memory region <address\-expression> \(or \-\-all\)",
         )
 
         # --all should match what repeating the command gives you
diff --git a/lldb/test/API/functionalities/target_var/TestTargetVar.py b/lldb/test/API/functionalities/target_var/TestTargetVar.py
index 54b7b77b6773c..a891ab1c1ac4d 100644
--- a/lldb/test/API/functionalities/target_var/TestTargetVar.py
+++ b/lldb/test/API/functionalities/target_var/TestTargetVar.py
@@ -27,7 +27,7 @@ def testTargetVarExpr(self):
         )
         self.expect("target variable i", substrs=["i", "42"])
         self.expect(
-            "target variable var", patterns=["\(incomplete \*\) var = 0[xX](0)*dead"]
+            "target variable var", patterns=[r"\(incomplete \*\) var = 0[xX](0)*dead"]
         )
         self.expect(
             "target variable var[0]",
diff --git a/lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py b/lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py
index b16869b05e7df..0c788b2cdfee3 100644
--- a/lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py
+++ b/lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py
@@ -55,7 +55,7 @@ def test_completion(self):
         self.child.expect(
             re.compile(
                 b"TestIOHandler(\r"
-                + self.cursor_forward_escape_seq("\d+")
+                + self.cursor_forward_escape_seq(r"\d+")
                 + b")?Completion.py"
             )
         )
diff --git a/lldb/test/API/lang/c/function_types/TestFunctionTypes.py b/lldb/test/API/lang/c/function_types/TestFunctionTypes.py
index 2f6bb7fc0bb16..6e42cd63573c9 100644
--- a/lldb/test/API/lang/c/function_types/TestFunctionTypes.py
+++ b/lldb/test/API/lang/c/function_types/TestFunctionTypes.py
@@ -54,7 +54,7 @@ def test_pointers(self):
         )
 
         if self.platformIsDarwin():
-            regexps = ["lib.*\.dylib`printf"]
+            regexps = [r"lib.*\.dylib`printf"]
         else:
             regexps = ["printf"]
         self.expect(
diff --git a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
index 0e51d4f7ff468..bcdd590e00d0a 100644
--- a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
+++ b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
@@ -9,7 +9,7 @@
 
 def re_expr_equals(val_type, val):
     # Match ({val_type}) ${sum_digits} = {val}
-    return re.compile(r"\(" + val_type + "\) \$\d+ = " + str(val))
+    return re.compile(r"\(" + val_type + r"\) \$\d+ = " + str(val))
 
 
 class RegisterVariableTestCase(TestBase):
diff --git a/lldb/test/API/lang/c/set_values/TestSetValues.py b/lldb/test/API/lang/c/set_values/TestSetValues.py
index 0d697d6719d5f..e0813734403a0 100644
--- a/lldb/test/API/lang/c/set_values/TestSetValues.py
+++ b/lldb/test/API/lang/c/set_values/TestSetValues.py
@@ -82,7 +82,7 @@ def test(self):
         self.expect(
             "frame variable --show-types",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\((short unsigned int|unsigned short)\) i = 33"],
+            patterns=[r"\((short unsigned int|unsigned short)\) i = 33"],
         )
 
         # Now set variable 'i' and check that it is correctly displayed.
@@ -90,7 +90,7 @@ def test(self):
         self.expect(
             "frame variable --show-types",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\((short unsigned int|unsigned short)\) i = 333"],
+            patterns=[r"\((short unsigned int|unsigned short)\) i = 333"],
         )
 
         self.runCmd("continue")
diff --git a/lldb/test/API/lang/c/strings/TestCStrings.py b/lldb/test/API/lang/c/strings/TestCStrings.py
index 159f8a4e4b664..f11006f7feefe 100644
--- a/lldb/test/API/lang/c/strings/TestCStrings.py
+++ b/lldb/test/API/lang/c/strings/TestCStrings.py
@@ -20,7 +20,7 @@ def test_with_run_command(self):
 
         self.runCmd("process launch", RUN_SUCCEEDED)
 
-        self.expect("expression -- a[2]", patterns=["\((const )?char\) \$0 = 'c'"])
+        self.expect("expression -- a[2]", patterns=[r"\((const )?char\) \$0 = 'c'"])
 
         self.expect("expression -- z[2]", startstr="(const char) $1 = 'x'")
 
diff --git a/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py b/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
index 2bffd2eea123a..56bb25b3f3c3d 100644
--- a/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
+++ b/lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
@@ -71,12 +71,12 @@ def test(self):
         self.expect(
             "expr var_static",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\(int\) \$.* = 88"],
+            patterns=[r"\(int\) \$.* = 88"],
         )
         self.expect(
             "expr var_shared",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\(int\) \$.* = 66"],
+            patterns=[r"\(int\) \$.* = 66"],
         )
 
         # Continue on the main thread
@@ -102,10 +102,10 @@ def test(self):
         self.expect(
             "expr var_static",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\(int\) \$.* = 44"],
+            patterns=[r"\(int\) \$.* = 44"],
         )
         self.expect(
             "expr var_shared",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\(int\) \$.* = 33"],
+            patterns=[r"\(int\) \$.* = 33"],
         )
diff --git a/lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py b/lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py
index e1cbe0509ae04..e2521d88258bc 100644
--- a/lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py
+++ b/lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py
@@ -74,8 +74,8 @@ def test(self):
         self.expect(
             "frame variable as16 as32",
             patterns=[
-                "\(char16_t\[[0-9]+\]\) as16 = ",
-                "\(char32_t\[[0-9]+\]\) as32 = ",
+                r"\(char16_t\[[0-9]+\]\) as16 = ",
+                r"\(char32_t\[[0-9]+\]\) as32 = ",
             ],
             substrs=['u"ﺸﺵۻ"', 'U"ЕЙРГЖО"'],
         )
@@ -103,8 +103,8 @@ def test(self):
         self.expect(
             "frame variable as16 as32",
             patterns=[
-                "\(char16_t\[[0-9]+\]\) as16 = ",
-                "\(char32_t\[[0-9]+\]\) as32 = ",
+                r"\(char16_t\[[0-9]+\]\) as16 = ",
+                r"\(char32_t\[[0-9]+\]\) as32 = ",
             ],
             substrs=['"色ハ匂ヘト散リヌルヲ"', '"෴"'],
         )
diff --git a/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py b/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
index 8211d532b2638..82c293c4d9b79 100644
--- a/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
+++ b/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
@@ -39,7 +39,7 @@ def test_with_run_command(self):
         self.expect(
             "target variable A::g_points",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\(PointType\[[1-9]*\]\) A::g_points = {"],
+            patterns=[r"\(PointType\[[1-9]*\]\) A::g_points = {"],
         )
         self.expect(
             "target variable g_points",
@@ -77,7 +77,7 @@ def test_with_run_command_complete(self):
             "target variable A::g_points",
             VARIABLES_DISPLAYED_CORRECTLY,
             patterns=[
-                "\(PointType\[[1-9]*\]\) A::g_points = {",
+                r"\(PointType\[[1-9]*\]\) A::g_points = {",
                 "(x = 1, y = 2)",
                 "(x = 11, y = 22)",
             ],
diff --git a/lldb/test/API/lang/cpp/class_types/TestClassTypes.py b/lldb/test/API/lang/cpp/class_types/TestClassTypes.py
index 80781f5d90912..b5d5dd2370781 100644
--- a/lldb/test/API/lang/cpp/class_types/TestClassTypes.py
+++ b/lldb/test/API/lang/cpp/class_types/TestClassTypes.py
@@ -179,7 +179,7 @@ def test_with_expr_parser(self):
         self.expect(
             "expression this->m_c_int",
             VARIABLES_DISPLAYED_CORRECTLY,
-            patterns=["\(int\) \$[0-9]+ = 66"],
+            patterns=[r"\(int\) \$[0-9]+ = 66"],
         )
 
     def test_with_constructor_name(self):
diff --git a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
index 60a2590e1559d..1d5ab15195df8 100644
--- a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
+++ b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
@@ -129,7 +129,7 @@ def test_get_dynamic_vals(self):
         self.expect(
             "frame var -d run-target --ptr-depth=2 --show-types anotherA.m_client_A",
             "frame var finds its way into a child member",
-            patterns=["\(B \*\)"],
+            patterns=[r"\(B \*\)"],
         )
 
         # Now make sure we also get it right for a reference as well:
diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index d747e2be77c8e..72a2445c990c0 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -231,12 +231,12 @@ def test_with_run_command(self):
 
         self.expect(
             "expression myanonfunc",
-            patterns=["\(anonymous namespace\)::myanonfunc\(int\)"],
+            patterns=[r"\(anonymous namespace\)::myanonfunc\(int\)"],
         )
 
         self.expect(
             "expression variadic_sum",
-            patterns=["\(anonymous namespace\)::variadic_sum\(int, ...\)"],
+            patterns=[r"\(anonymous namespace\)::variadic_sum\(int, ...\)"],
         )
 
         self.expect_expr("::B::Bar b; b.x()", result_type="int", result_value="42")
diff --git a/lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py b/lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
index a08c2e721328d..b8c2c23613868 100644
--- a/lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
+++ b/lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
@@ -57,8 +57,8 @@ def test(self):
             "frame variable --show-types --no-args",
             VARIABLES_DISPLAYED_CORRECTLY,
             patterns=[
-                "\((short int|short)\) the_signed_short = 99",
-                "\((signed char|char)\) the_signed_char = 'c'",
+                r"\((short int|short)\) the_signed_short = 99",
+                r"\((signed char|char)\) the_signed_char = 'c'",
             ],
             substrs=[
                 "(int) the_signed_int = 99",
diff --git a/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py b/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py
index ffce9534e05bd..4796c84966675 100644
--- a/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py
+++ b/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py
@@ -22,7 +22,7 @@ def test(self):
             "frame variable --show-types --no-args",
             VARIABLES_DISPLAYED_CORRECTLY,
             patterns=[
-                "\((short unsigned int|unsigned short)\) the_unsigned_short = 99"
+                r"\((short unsigned int|unsigned short)\) the_unsigned_short = 99"
             ],
             substrs=[
                 "(unsigned char) the_unsigned_char = 'c'",
diff --git a/lldb/test/API/lang/mixed/TestMixedLanguages.py b/lldb/test/API/lang/mixed/TestMixedLanguages.py
index 8b73254cce4a9..a31e3873116ff 100644
--- a/lldb/test/API/lang/mixed/TestMixedLanguages.py
+++ b/lldb/test/API/lang/mixed/TestMixedLanguages.py
@@ -22,12 +22,12 @@ def cleanup():
 
         self.addTearDownHook(cleanup)
         self.runCmd("settings show frame-format")
-        m = re.match('^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
+        m = re.match(r'^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
         self.assertTrue(m, "Bad settings string")
         self.format_string = m.group(1)
 
         # Change the default format to print the language.
-        format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n"
+        format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n"
         self.runCmd("settings set frame-format %s" % format_string)
         self.expect(
             "settings show frame-format",
diff --git a/lldb/test/API/lang/objc/foundation/TestObjCMethods.py b/lldb/test/API/lang/objc/foundation/TestObjCMethods.py
index 634e4730c764b..5fa3f280d33bf 100644
--- a/lldb/test/API/lang/objc/foundation/TestObjCMethods.py
+++ b/lldb/test/API/lang/objc/foundation/TestObjCMethods.py
@@ -166,7 +166,7 @@ def test_data_type_and_expr(self):
             "frame variable --show-types --scope",
             VARIABLES_DISPLAYED_CORRECTLY,
             substrs=["ARG: (MyString *) self"],
-            patterns=["ARG: \(.*\) _cmd", "(objc_selector *)|(SEL)"],
+            patterns=[r"ARG: \(.*\) _cmd", "(objc_selector *)|(SEL)"],
         )
 
         # rdar://problem/8651752
diff --git a/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py b/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py
index 81c409d08364c..2cd1386289b9e 100644
--- a/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py
+++ b/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py
@@ -19,10 +19,10 @@ def test_NSArray_expr_commands(self):
 
         self.runCmd("thread backtrace")
         self.expect(
-            "expression (int)[nil_mutable_array count]", patterns=["\(int\) \$.* = 0"]
+            "expression (int)[nil_mutable_array count]", patterns=[r"\(int\) \$.* = 0"]
         )
-        self.expect("expression (int)[array1 count]", patterns=["\(int\) \$.* = 3"])
-        self.expect("expression (int)[array2 count]", patterns=["\(int\) \$.* = 3"])
-        self.expect("expression (int)array1.count", patterns=["\(int\) \$.* = 3"])
-        self.expect("expression (int)array2.count", patterns=["\(int\) \$.* = 3"])
+        self.expect("expression (int)[array1 count]", patterns=[r"\(int\) \$.* = 3"])
+        self.expect("expression (int)[array2 count]", patterns=[r"\(int\) \$.* = 3"])
+        self.expect("expression (int)array1.count", patterns=[r"\(int\) \$.* = 3"])
+        self.expect("expression (int)array2.count", patterns=[r"\(int\) \$.* = 3"])
         self.runCmd("process continue")
diff --git a/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py b/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py
index c9e801422b46c..a14035db5e057 100644
--- a/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py
+++ b/lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py
@@ -20,7 +20,7 @@ def test_runtime_types(self):
 
         # Test_NSString:
         self.runCmd("thread backtrace")
-        self.expect("expression [str length]", patterns=["\(NSUInteger\) \$.* ="])
+        self.expect("expression [str length]", patterns=[r"\(NSUInteger\) \$.* ="])
         self.expect("expression str.length")
         self.expect('expression str = [NSString stringWithCString: "new"]')
         self.expect(
diff --git a/lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py b/lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py
index 4d8c9c960ea59..3e33077b8e2d7 100644
--- a/lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py
+++ b/lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py
@@ -21,11 +21,11 @@ def test_NSString_expr_commands(self):
 
         # Test_NSString:
         self.runCmd("thread backtrace")
-        self.expect("expression (int)[str length]", patterns=["\(int\) \$.* ="])
-        self.expect("expression (int)[str_id length]", patterns=["\(int\) \$.* ="])
-        self.expect("expression (id)[str description]", patterns=["\(id\) \$.* = 0x"])
+        self.expect("expression (int)[str length]", patterns=[r"\(int\) \$.* ="])
+        self.expect("expression (int)[str_id length]", patterns=[r"\(int\) \$.* ="])
+        self.expect("expression (id)[str description]", patterns=[r"\(id\) \$.* = 0x"])
         self.expect(
-            "expression (id)[str_id description]", patterns=["\(id\) \$.* = 0x"]
+            "expression (id)[str_id description]", patterns=[r"\(id\) \$.* = 0x"]
         )
         self.expect("expression str.length")
         self.expect('expression str = @"new"')
@@ -42,6 +42,6 @@ def test_MyString_dump_with_runtime(self):
         )
         self.expect(
             "expression --show-types -- *my",
-            patterns=["\(MyString\) \$.* = ", "\(MyBase\)"],
+            patterns=[r"\(MyString\) \$.* = ", r"\(MyBase\)"],
         )
         self.runCmd("process continue")
diff --git a/lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py b/lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
index 3ba68f4c35a5c..4d439fa0046e4 100644
--- a/lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
+++ b/lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
@@ -107,7 +107,7 @@ def test_get_objc_dynamic_vals(self):
         self.expect(
             "frame var -d run-target myObserver->_source",
             "frame var finds its way into a child member",
-            patterns=["\(SourceDerived \*\)"],
+            patterns=[r"\(SourceDerived \*\)"],
         )
 
         # check that our ObjC GetISA() does a good job at hiding KVO swizzled
diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 3cdca31b8969b..ac107de7e00a7 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -51,11 +51,11 @@ def test_with_python_api(self):
         frame = thread_list[0].GetFrameAtIndex(0)
         self.assertTrue(frame, "Got a valid frame 0 frame.")
 
-        self.expect("expr (foo)", patterns=["\(ns::id\) \$.* = 0"])
+        self.expect("expr (foo)", patterns=[r"\(ns::id\) \$.* = 0"])
 
         self.expect(
             "expr --language Objective-C++ -- id my_id = 0; my_id",
-            patterns=["\(id\) \$.* = nil"],
+            patterns=[r"\(id\) \$.* = nil"],
         )
         self.expect("expr --language C++ -- id my_id = 0; my_id", error=True)
 
diff --git a/lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py b/lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
index 045f8c0a70108..6db4f956979eb 100644
--- a/lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
+++ b/lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
@@ -89,9 +89,9 @@ def test_mte_tag_core_file_tag_read(self):
             "memory tag read {addr}+16 {addr}".format(addr=self.MTE_BUF_ADDR),
             error=True,
             patterns=[
-                "error: End address \(0x[A-Fa-f0-9]+\) "
+                r"error: End address \(0x[A-Fa-f0-9]+\) "
                 "must be greater than the start address "
-                "\(0x[A-Fa-f0-9]+\)"
+                r"\(0x[A-Fa-f0-9]+\)"
             ],
         )
 
@@ -101,8 +101,8 @@ def test_mte_tag_core_file_tag_read(self):
             "memory tag read {addr} {addr}+32".format(addr=self.MTE_BUF_ADDR),
             patterns=[
                 "Allocation tags:\n"
-                "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n"
-                "\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$"
+                "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
+                "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)$"
             ],
         )
 
@@ -111,7 +111,7 @@ def test_mte_tag_core_file_tag_read(self):
         self.expect(
             "memory tag read {addr} {addr}+16".format(addr=self.MTE_BUF_ADDR),
             patterns=[
-                "Allocation tags:\n" "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$"
+                "Allocation tags:\n" r"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$"
             ],
         )
         # Get the other half of the first byte.
@@ -120,7 +120,7 @@ def test_mte_tag_core_file_tag_read(self):
             "memory tag read {addr}+16 {addr}+32".format(addr=self.MTE_BUF_ADDR),
             patterns=[
                 "Allocation tags:\n"
-                "\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$"
+                r"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$"
             ],
         )
 
@@ -129,18 +129,18 @@ def test_mte_tag_core_file_tag_read(self):
             "memory tag read {addr} {addr}+48".format(addr=self.MTE_BUF_ADDR),
             patterns=[
                 "Allocation tags:\n"
-                "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n"
-                "\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n"
-                "\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)$"
+                "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
+                "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n"
+                "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)$"
             ],
         )
         self.expect(
             "memory tag read {addr}+16 {addr}+64".format(addr=self.MTE_BUF_ADDR),
             patterns=[
                 "Allocation tags:\n"
-                "\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n"
-                "\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)\n"
-                "\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\): 0x3 \(mismatch\)$"
+                "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n"
+                "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)\n"
+                "\\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\\): 0x3 \\(mismatch\\)$"
             ],
         )
         # Here both start and end are unaligned.
@@ -148,10 +148,10 @@ def test_mte_tag_core_file_tag_read(self):
             "memory tag read {addr}+16 {addr}+80".format(addr=self.MTE_BUF_ADDR),
             patterns=[
                 "Allocation tags:\n"
-                "\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n"
-                "\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)\n"
-                "\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\): 0x3 \(mismatch\)\n"
-                "\[0x[A-Fa-f0-9]+40, 0x[A-Fa-f0-9]+50\): 0x4 \(mismatch\)$"
+                "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n"
+                "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)\n"
+                "\\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\\): 0x3 \\(mismatch\\)\n"
+                "\\[0x[A-Fa-f0-9]+40, 0x[A-Fa-f0-9]+50\\): 0x4 \\(mismatch\\)$"
             ],
         )
 
@@ -160,7 +160,7 @@ def test_mte_tag_core_file_tag_read(self):
         self.expect(
             "memory tag read {addr} {addr}+1".format(addr=self.MTE_BUF_ADDR),
             patterns=[
-                "Allocation tags:\n" "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$"
+                "Allocation tags:\n" r"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$"
             ],
         )
 
@@ -170,8 +170,8 @@ def test_mte_tag_core_file_tag_read(self):
             "memory tag read {addr} {addr}+17".format(addr=self.MTE_BUF_ADDR),
             patterns=[
                 "Allocation tags:\n"
-                "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n"
-                "\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$"
+                "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
+                "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)$"
             ],
         )
 
@@ -180,9 +180,9 @@ def test_mte_tag_core_file_tag_read(self):
             "memory tag read {addr} {addr}+33".format(addr=self.MTE_BUF_ADDR),
             patterns=[
                 "Allocation tags:\n"
-                "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n"
-                "\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n",
-                "\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)$",
+                "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
+                "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n",
+                "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)$",
             ],
         )
 
diff --git a/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py b/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
index c72eb72b05cce..bbc621814a47a 100644
--- a/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
+++ b/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
@@ -86,8 +86,8 @@ def test_mte_tag_read(self):
         self.expect(
             "memory tag read mte_buf mte_buf-16",
             patterns=[
-                "error: End address \(0x[A-Fa-f0-9]+\) must be "
-                "greater than the start address \(0x[A-Fa-f0-9]+\)"
+                r"error: End address \(0x[A-Fa-f0-9]+\) must be "
+                r"greater than the start address \(0x[A-Fa-f0-9]+\)"
             ],
             error=True,
         )
@@ -95,8 +95,8 @@ def test_mte_tag_read(self):
         self.expect(
             "memory tag read mte_buf mte_buf",
             patterns=[
-                "error: End address \(0x[A-Fa-f0-9]+\) must be "
-                "greater than the start address \(0x[A-Fa-f0-9]+\)"
+                r"error: End address \(0x[A-Fa-f0-9]+\) must be "
+                r"greater than the start address \(0x[A-Fa-f0-9]+\)"
             ],
             error=True,
         )
@@ -117,7 +117,7 @@ def test_mte_tag_read(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
+                r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
             ],
         )
 
@@ -127,7 +127,7 @@ def test_mte_tag_read(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
+                r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
             ],
         )
 
@@ -137,8 +137,8 @@ def test_mte_tag_read(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x1 \(mismatch\)$"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x0 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x1 \\(mismatch\\)$"
             ],
         )
 
@@ -150,7 +150,7 @@ def test_mte_tag_read(self):
             patterns=[
                 "Logical tag: 0x0\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0x0$"
+                r"\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0x0$"
             ],
         )
 
@@ -179,8 +179,8 @@ def test_mte_tag_read(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\): 0xf \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
+                "\\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\\): 0xf \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x0 \\(mismatch\\)$"
             ],
         )
 
@@ -192,7 +192,7 @@ def test_mte_tag_read(self):
             patterns=[
                 "Logical tag: 0xa\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
+                r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
             ],
         )
 
@@ -202,9 +202,9 @@ def test_mte_tag_read(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+80, 0x[0-9A-Fa-f]+90\): 0x8 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+90, 0x[0-9A-Fa-f]+a0\): 0x9\n"
-                "\[0x[0-9A-Fa-f]+a0, 0x[0-9A-Fa-f]+b0\): 0xa \(mismatch\)$"
+                "\\[0x[0-9A-Fa-f]+80, 0x[0-9A-Fa-f]+90\\): 0x8 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+90, 0x[0-9A-Fa-f]+a0\\): 0x9\n"
+                "\\[0x[0-9A-Fa-f]+a0, 0x[0-9A-Fa-f]+b0\\): 0xa \\(mismatch\\)$"
             ],
         )
 
@@ -258,8 +258,8 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x9\n"
-                "\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x1 \(mismatch\)$"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x9\n"
+                "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x1 \\(mismatch\\)$"
             ],
         )
 
@@ -270,9 +270,9 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0xa \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0xb \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0xc \(mismatch\)$"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0xa \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0xb \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0xc \\(mismatch\\)$"
             ],
         )
 
@@ -284,7 +284,7 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x0\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0xe \(mismatch\)$"
+                r"\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0xe \(mismatch\)$"
             ],
         )
 
@@ -323,8 +323,8 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x9\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\): 0x1 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x2 \(mismatch\)$"
+                "\\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\\): 0x1 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x2 \\(mismatch\\)$"
             ],
         )
 
@@ -335,7 +335,7 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x0\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x1 \(mismatch\)$"
+                r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x1 \(mismatch\)$"
             ],
         )
 
@@ -361,16 +361,16 @@ def test_mte_tag_write(self):
         self.expect(
             "memory tag write mte_buf_2 9 --end-addr mte_buf_2",
             patterns=[
-                "error: End address \(0x[A-Fa-f0-9]+\) must be "
-                "greater than the start address \(0x[A-Fa-f0-9]+\)"
+                r"error: End address \(0x[A-Fa-f0-9]+\) must be "
+                r"greater than the start address \(0x[A-Fa-f0-9]+\)"
             ],
             error=True,
         )
         self.expect(
             "memory tag write mte_buf_2 9 --end-addr mte_buf_2-16",
             patterns=[
-                "error: End address \(0x[A-Fa-f0-9]+\) must be "
-                "greater than the start address \(0x[A-Fa-f0-9]+\)"
+                r"error: End address \(0x[A-Fa-f0-9]+\) must be "
+                r"greater than the start address \(0x[A-Fa-f0-9]+\)"
             ],
             error=True,
         )
@@ -391,10 +391,10 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x0\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x4 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x5 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0x4 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\): 0x0$"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x4 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x5 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0x4 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\\): 0x0$"
             ],
         )
 
@@ -409,9 +409,9 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x0\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x6 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x6 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0x4 \(mismatch\)$"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x6 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x6 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0x4 \\(mismatch\\)$"
             ],
         )
 
@@ -423,10 +423,10 @@ def test_mte_tag_write(self):
             patterns=[
                 "Logical tag: 0x0\n"
                 "Allocation tags:\n"
-                "\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x3 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x3 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0x3 \(mismatch\)\n"
-                "\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\): 0x0$"
+                "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x3 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x3 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0x3 \\(mismatch\\)\n"
+                "\\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\\): 0x0$"
             ],
         )
 
@@ -452,8 +452,8 @@ def test_mte_memory_read_tag_display(self):
         self.expect(
             'memory read mte_buf mte_buf+32 -f "x" -l 1 -s 16 --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n"
-                "0x[0-9A-Fa-f]+10: 0x0+ \(tag: 0x1\)"
+                "0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n"
+                "0x[0-9A-Fa-f]+10: 0x0+ \\(tag: 0x1\\)"
             ],
         )
 
@@ -461,13 +461,13 @@ def test_mte_memory_read_tag_display(self):
         # per line.
         self.expect(
             'memory read mte_buf mte_buf+32 -f "x" -l 1 -s 32 --show-tags',
-            patterns=["0x[0-9A-Fa-f]+00: 0x0+ \(tags: 0x0 0x1\)\n"],
+            patterns=["0x[0-9A-Fa-f]+00: 0x0+ \\(tags: 0x0 0x1\\)\n"],
         )
 
         # Reading half a granule still shows you the tag for that granule
         self.expect(
             'memory read mte_buf mte_buf+8 -f "x" -l 1 -s 8 --show-tags',
-            patterns=["0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n"],
+            patterns=["0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n"],
         )
 
         # We can read a whole number of granules but split them over more lines
@@ -475,10 +475,10 @@ def test_mte_memory_read_tag_display(self):
         self.expect(
             'memory read mte_buf+32 mte_buf+64 -f "x" -l 1 -s 8 --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+20: 0x0+ \(tag: 0x2\)\n"
-                "0x[0-9A-Fa-f]+28: 0x0+ \(tag: 0x2\)\n"
-                "0x[0-9A-Fa-f]+30: 0x0+ \(tag: 0x3\)\n"
-                "0x[0-9A-Fa-f]+38: 0x0+ \(tag: 0x3\)"
+                "0x[0-9A-Fa-f]+20: 0x0+ \\(tag: 0x2\\)\n"
+                "0x[0-9A-Fa-f]+28: 0x0+ \\(tag: 0x2\\)\n"
+                "0x[0-9A-Fa-f]+30: 0x0+ \\(tag: 0x3\\)\n"
+                "0x[0-9A-Fa-f]+38: 0x0+ \\(tag: 0x3\\)"
             ],
         )
 
@@ -488,10 +488,10 @@ def test_mte_memory_read_tag_display(self):
         self.expect(
             'memory read mte_buf+32+8 mte_buf+64+8 -f "x" -l 1 -s 8 --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+28: 0x0+ \(tag: 0x2\)\n"
-                "0x[0-9A-Fa-f]+30: 0x0+ \(tag: 0x3\)\n"
-                "0x[0-9A-Fa-f]+38: 0x0+ \(tag: 0x3\)\n"
-                "0x[0-9A-Fa-f]+40: 0x0+ \(tag: 0x4\)"
+                "0x[0-9A-Fa-f]+28: 0x0+ \\(tag: 0x2\\)\n"
+                "0x[0-9A-Fa-f]+30: 0x0+ \\(tag: 0x3\\)\n"
+                "0x[0-9A-Fa-f]+38: 0x0+ \\(tag: 0x3\\)\n"
+                "0x[0-9A-Fa-f]+40: 0x0+ \\(tag: 0x4\\)"
             ],
         )
 
@@ -501,10 +501,10 @@ def test_mte_memory_read_tag_display(self):
         self.expect(
             'memory read mte_buf+32+4 mte_buf+64+4 -f "x" -l 1 -s 8 --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+24: 0x0+ \(tag: 0x2\)\n"
-                "0x[0-9A-Fa-f]+2c: 0x0+ \(tags: 0x2 0x3\)\n"
-                "0x[0-9A-Fa-f]+34: 0x0+ \(tag: 0x3\)\n"
-                "0x[0-9A-Fa-f]+3c: 0x0+ \(tags: 0x3 0x4\)"
+                "0x[0-9A-Fa-f]+24: 0x0+ \\(tag: 0x2\\)\n"
+                "0x[0-9A-Fa-f]+2c: 0x0+ \\(tags: 0x2 0x3\\)\n"
+                "0x[0-9A-Fa-f]+34: 0x0+ \\(tag: 0x3\\)\n"
+                "0x[0-9A-Fa-f]+3c: 0x0+ \\(tags: 0x3 0x4\\)"
             ],
         )
 
@@ -516,15 +516,15 @@ def test_mte_memory_read_tag_display(self):
             'memory read mte_buf-16 mte_buf+32 -f "x" -l 1 -s 16 --show-tags',
             patterns=[
                 "0x[0-9A-Fa-f]+f0: 0x0+\n"
-                "0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n"
-                "0x[0-9A-Fa-f]+10: 0x0+ \(tag: 0x1\)"
+                "0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n"
+                "0x[0-9A-Fa-f]+10: 0x0+ \\(tag: 0x1\\)"
             ],
         )
 
         # End of range is untagged
         self.expect(
             'memory read mte_buf+page_size-16 mte_buf+page_size+16 -f "x" -l 1 -s 16 --show-tags',
-            patterns=["0x[0-9A-Fa-f]+f0: 0x0+ \(tag: 0xf\)\n" "0x[0-9A-Fa-f]+00: 0x0+"],
+            patterns=["0x[0-9A-Fa-f]+f0: 0x0+ \\(tag: 0xf\\)\n" "0x[0-9A-Fa-f]+00: 0x0+"],
         )
 
         # The smallest MTE range we can get is a single page so we just check
@@ -533,8 +533,8 @@ def test_mte_memory_read_tag_display(self):
         self.expect(
             'memory read mte_read_only-16 mte_read_only+page_size+16 -f "x" -l 1 -s 16 --force --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+f0: 0x0+\n" "0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n",
-                "0x[0-9A-Fa-f]+f0: 0x0+ \(tag: 0x0\)\n" "0x[0-9A-Fa-f]+00: 0x0+",
+                "0x[0-9A-Fa-f]+f0: 0x0+\n" "0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n",
+                "0x[0-9A-Fa-f]+f0: 0x0+ \\(tag: 0x0\\)\n" "0x[0-9A-Fa-f]+00: 0x0+",
             ],
         )
 
@@ -542,21 +542,21 @@ def test_mte_memory_read_tag_display(self):
         # <no tag> is shown in where the tag would be, to keep the order intact.
         self.expect(
             'memory read mte_buf-16 mte_buf+32 -f "x" -l 1 -s 32 --show-tags',
-            patterns=["0x[0-9A-Fa-f]+f0: 0x0+ \(tags: <no tag> 0x0\)"],
+            patterns=[r"0x[0-9A-Fa-f]+f0: 0x0+ \(tags: <no tag> 0x0\)"],
         )
         self.expect(
             'memory read mte_read_only+page_size-16 mte_read_only+page_size+16 -f "x" -l 1 -s 32  --show-tags',
-            patterns=["0x[0-9A-Fa-f]+f0: 0x0+ \(tags: 0x0 <no tag>\)"],
+            patterns=[r"0x[0-9A-Fa-f]+f0: 0x0+ \(tags: 0x0 <no tag>\)"],
         )
 
         # Here the start address is unaligned so we cover 3 granules instead of 2
         self.expect(
             'memory read mte_buf-16+4 mte_buf+32+4 -f "x" -l 1 -s 32 --show-tags',
-            patterns=["0x[0-9A-Fa-f]+f4: 0x0+ \(tags: <no tag> 0x0 0x1\)"],
+            patterns=[r"0x[0-9A-Fa-f]+f4: 0x0+ \(tags: <no tag> 0x0 0x1\)"],
         )
         self.expect(
             'memory read mte_read_only+page_size-16+4 mte_read_only+page_size+16+4 -f "x" -l 1 -s 32 --show-tags',
-            patterns=["0x[0-9A-Fa-f]+f4: 0x0+ \(tags: 0x0 <no tag> <no tag>\)"],
+            patterns=[r"0x[0-9A-Fa-f]+f4: 0x0+ \(tags: 0x0 <no tag> <no tag>\)"],
         )
 
         # Some formats call DumpDataExtractor multiple times,
@@ -564,24 +564,24 @@ def test_mte_memory_read_tag_display(self):
         self.expect(
             'memory read mte_buf mte_buf+32 -f "x" --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x0\)\n",
-                "0x[0-9A-Fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x1\)",
+                "0x[0-9A-Fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \\(tag: 0x0\\)\n",
+                "0x[0-9A-Fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \\(tag: 0x1\\)",
             ],
         )
 
         self.expect(
             'memory read mte_buf mte_buf+32 -f "bytes with ASCII" --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+00: (00 ){16} \.{16} \(tag: 0x0\)\n",
-                "0x[0-9A-Fa-f]+10: (00 ){16} \.{16} \(tag: 0x1\)",
+                "0x[0-9A-Fa-f]+00: (00 ){16} \\.{16} \\(tag: 0x0\\)\n",
+                "0x[0-9A-Fa-f]+10: (00 ){16} \\.{16} \\(tag: 0x1\\)",
             ],
         )
 
         self.expect(
             'memory read mte_buf mte_buf+32 -f "uint8_t[]" -s 16 -l 1 --show-tags',
             patterns=[
-                "0x[0-9A-Fa-f]+00: \{(0x00 ){15}0x00\} \(tag: 0x0\)\n"
-                "0x[0-9A-Fa-f]+10: \{(0x00 ){15}0x00\} \(tag: 0x1\)"
+                "0x[0-9A-Fa-f]+00: \\{(0x00 ){15}0x00\\} \\(tag: 0x0\\)\n"
+                "0x[0-9A-Fa-f]+10: \\{(0x00 ){15}0x00\\} \\(tag: 0x1\\)"
             ],
         )
 
@@ -594,12 +594,12 @@ def test_mte_memory_read_tag_display_repeated(self):
 
         self.expect(
             'memory read mte_buf mte_buf+16 -f "x" --show-tags',
-            patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x0\)"],
+            patterns=[r"0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x0\)"],
         )
         # Equivalent to just pressing enter on the command line.
         self.expect(
             "memory read",
-            patterns=["0x[0-9A-fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x1\)"],
+            patterns=[r"0x[0-9A-fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x1\)"],
         )
 
         # You can add the argument to an existing repetition without resetting
@@ -613,10 +613,10 @@ def test_mte_memory_read_tag_display_repeated(self):
         # Note that the formatting returns to default here.
         self.expect(
             "memory read --show-tags",
-            patterns=["0x[0-9A-fa-f]+20: (00 )+ \.+ \(tag: 0x2\)"],
+            patterns=[r"0x[0-9A-fa-f]+20: (00 )+ \.+ \(tag: 0x2\)"],
         )
         self.expect(
-            "memory read", patterns=["0x[0-9A-fa-f]+30: (00 )+ \.+ \(tag: 0x3\)"]
+            "memory read", patterns=[r"0x[0-9A-fa-f]+30: (00 )+ \.+ \(tag: 0x3\)"]
         )
 
         # A fresh command reverts to the default of tags being off.
@@ -641,8 +641,8 @@ def test_mte_memory_find(self):
         cmd = 'memory find -s "LLDB" mte_buf+64 mte_buf+512'
         found_pattern = "data found at location: 0x[0-9A-Fa-f]+80"
         results_patterns = [
-            "0x[0-9A-Fa-f]+80: 4c 4c 44 42 (00 )+ LLDB\.+",
-            "0x[0-9A-Fa-f]+90: 00 00 00 00 (00 )+ \.+",
+            r"0x[0-9A-Fa-f]+80: 4c 4c 44 42 (00 )+ LLDB\.+",
+            r"0x[0-9A-Fa-f]+90: 00 00 00 00 (00 )+ \.+",
         ]
 
         # Default is not to show tags
@@ -651,8 +651,8 @@ def test_mte_memory_find(self):
             cmd + " --show-tags",
             patterns=[
                 found_pattern,
-                results_patterns[0] + " \(tag: 0x8\)",
-                results_patterns[1] + " \(tag: 0x9\)",
+                results_patterns[0] + r" \(tag: 0x8\)",
+                results_patterns[1] + r" \(tag: 0x9\)",
             ],
         )
 
@@ -661,7 +661,7 @@ def test_mte_memory_find(self):
             'memory find -s "DB" mte_buf+64 mte_buf+512 --show-tags',
             patterns=[
                 "data found at location: 0x[0-9A-Fa-f]+82\n"
-                "0x[0-9A-Fa-f]+82: 44 42 (00 )+ DB\.+ \(tags: 0x8 0x9\)\n",
-                "0x[0-9A-Fa-f]+92: 00 00 (00 )+ ..\.+ \(tags: 0x9 0xa\)",
+                "0x[0-9A-Fa-f]+82: 44 42 (00 )+ DB\\.+ \\(tags: 0x8 0x9\\)\n",
+                "0x[0-9A-Fa-f]+92: 00 00 (00 )+ ..\\.+ \\(tags: 0x9 0xa\\)",
             ],
         )
diff --git a/lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py b/lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py
index 420aae4823488..180a3f67df67a 100644
--- a/lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py
+++ b/lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py
@@ -50,9 +50,9 @@ def test_mte_tag_fault_sync(self):
         self.expect(
             "continue",
             patterns=[
-                "\* thread #1, name = 'a.out', stop reason = signal SIGSEGV: "
-                "sync tag check fault \(fault address: 0x9[0-9A-Fa-f]+11\ "
-                "logical tag: 0x9 allocation tag: 0xa\)"
+                r"\* thread #1, name = 'a.out', stop reason = signal SIGSEGV: "
+                r"sync tag check fault \(fault address: 0x9[0-9A-Fa-f]+11\ "
+                r"logical tag: 0x9 allocation tag: 0xa\)"
             ],
         )
 
diff --git a/lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py b/lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py
index 8eadd65466a49..9c4799a533905 100644
--- a/lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py
+++ b/lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py
@@ -39,7 +39,7 @@ def test_mte_regions(self):
 
         # Despite the non address bits we should find a region
         self.expect(
-            "memory region the_page", patterns=["\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"]
+            "memory region the_page", patterns=[r"\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"]
         )
 
         # Check that the usual error message is displayed after repeating
@@ -68,5 +68,5 @@ def test_mte_regions(self):
         # This should not error, since the user supplied address overrides
         # the previous end address.
         self.expect(
-            "memory region the_page", patterns=["\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"]
+            "memory region the_page", patterns=[r"\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"]
         )
diff --git a/lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py b/lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
index 52055f250a584..8ff72c9a74edd 100644
--- a/lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
+++ b/lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
@@ -6,7 +6,7 @@
 
 @skipUnlessDarwin
 class AddDsymDownload(TestBase):
-    dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
+    dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
 
     def get_uuid(self):
         dwarfdump_cmd_output = subprocess.check_output(
diff --git a/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py b/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
index db3074d7e7942..9309de4824ec4 100644
--- a/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
+++ b/lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
@@ -285,7 +285,7 @@ def test_lc_note_main_bin_spec_os_plugin(self):
             for l in python_init:
                 writer.write(l + "\n")
 
-        dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
+        dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
         dwarfdump_cmd_output = subprocess.check_output(
             ('/usr/bin/dwarfdump --uuid "%s"' % aout_exe), shell=True
         ).decode("utf-8")
diff --git a/lldb/test/API/macosx/lc-note/kern-ver-str/TestKernVerStrLCNOTE.py b/lldb/test/API/macosx/lc-note/kern-ver-str/TestKernVerStrLCNOTE.py
index d4366196c53c3..a3f9144572da5 100644
--- a/lldb/test/API/macosx/lc-note/kern-ver-str/TestKernVerStrLCNOTE.py
+++ b/lldb/test/API/macosx/lc-note/kern-ver-str/TestKernVerStrLCNOTE.py
@@ -32,7 +32,7 @@ def test_lc_note(self):
             lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None)
         )
 
-        dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
+        dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
         dwarfdump_cmd_output = subprocess.check_output(
             ('/usr/bin/dwarfdump --uuid "%s"' % self.test_exe), shell=True
         ).decode("utf-8")
diff --git a/lldb/test/API/macosx/lc-note/multiple-binary-corefile/TestMultipleBinaryCorefile.py b/lldb/test/API/macosx/lc-note/multiple-binary-corefile/TestMultipleBinaryCorefile.py
index 897eab23e05e2..28472cb787d4a 100644
--- a/lldb/test/API/macosx/lc-note/multiple-binary-corefile/TestMultipleBinaryCorefile.py
+++ b/lldb/test/API/macosx/lc-note/multiple-binary-corefile/TestMultipleBinaryCorefile.py
@@ -107,7 +107,7 @@ def test_corefile_binaries_dsymforuuid(self):
             )
         )
 
-        dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
+        dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
         dwarfdump_cmd_output = subprocess.check_output(
             ('/usr/bin/dwarfdump --uuid "%s"' % self.libtwo_exe), shell=True
         ).decode("utf-8")
diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index b712afdd7560a..9790190c8aaa9 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -72,7 +72,7 @@ def run_with(self, arch, os, vers, env, expected_load_command):
             self, "break here", lldb.SBFileSpec("hello.c")
         )
         triple_re = "-".join([arch, "apple", os + vers + ".*"] + env_list)
-        self.expect("image list -b -t", patterns=["a\.out " + triple_re])
+        self.expect("image list -b -t", patterns=[r"a\.out " + triple_re])
         self.check_debugserver(log, os + env, vers)
 
     @skipIfAsan
diff --git a/lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py b/lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py
index 138792d817dbf..3ed817f5f5f84 100644
--- a/lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py
+++ b/lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py
@@ -43,7 +43,7 @@ def test_lc_note(self):
             lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None)
         )
 
-        dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
+        dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
         dwarfdump_cmd_output = subprocess.check_output(
             ('/usr/bin/dwarfdump --uuid "%s"' % self.aout_exe), shell=True
         ).decode("utf-8")
diff --git a/lldb/test/API/python_api/target-arch-from-module/TestTargetArchFromModule.py b/lldb/test/API/python_api/target-arch-from-module/TestTargetArchFromModule.py
index 260f37c9ed230..0141828ae1eab 100644
--- a/lldb/test/API/python_api/target-arch-from-module/TestTargetArchFromModule.py
+++ b/lldb/test/API/python_api/target-arch-from-module/TestTargetArchFromModule.py
@@ -34,7 +34,7 @@ def test_target_arch_init(self):
             lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None)
         )
 
-        dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
+        dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
         dwarfdump_cmd_output = subprocess.check_output(
             ('/usr/bin/dwarfdump --uuid "%s"' % aout_exe), shell=True
         ).decode("utf-8")
diff --git a/lldb/test/API/source-manager/TestSourceManager.py b/lldb/test/API/source-manager/TestSourceManager.py
index ad7c85aac70ea..589192ba67495 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -256,7 +256,7 @@ def test_modify_source_file_while_debugging(self):
         # of breakpoints for the current line, i.e., self.line.
         import re
 
-        m = re.search("^\[(\d+)\].*// Set break point at this line.", output)
+        m = re.search(r"^\[(\d+)\].*// Set break point at this line.", output)
         if not m:
             self.fail("Fail to display source level breakpoints")
         self.assertGreater(int(m.group(1)), 0)
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py
index 132072547e207..c8055f9b6320c 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py
@@ -42,7 +42,7 @@ def test_module_info(self):
         context = self.expect_gdbremote_sequence()
         spec = context.get("spec")
         self.assertRegex(spec, '"file_path":".*"')
-        self.assertRegex(spec, '"file_offset":\d+')
-        self.assertRegex(spec, '"file_size":\d+')
-        self.assertRegex(spec, '"triple":"\w*-\w*-.*"')
+        self.assertRegex(spec, r'"file_offset":\d+')
+        self.assertRegex(spec, r'"file_size":\d+')
+        self.assertRegex(spec, r'"triple":"\w*-\w*-.*"')
         self.assertRegex(spec, '"uuid":"[A-Fa-f0-9]+"')
diff --git a/lldb/test/API/tools/lldb-server/TestPtyServer.py b/lldb/test/API/tools/lldb-server/TestPtyServer.py
index 4bfcf70bfa01b..9d67580df1be3 100644
--- a/lldb/test/API/tools/lldb-server/TestPtyServer.py
+++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -64,7 +64,7 @@ def test_pty_server(self):
                 "read packet: $qXfer:features:read:target.xml:0,200000#00",
                 {
                     "direction": "send",
-                    "regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
+                    "regex": re.compile(r"^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
                     "capture": {1: "target_xml"},
                 },
             ],
diff --git a/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py b/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
index bd78a83c65655..c1a92eeb5d5d1 100644
--- a/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
+++ b/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
@@ -24,7 +24,7 @@ def test_g_target_xml_returns_correct_data(self):
                 ),
                 {
                     "direction": "send",
-                    "regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
+                    "regex": re.compile(r"^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
                     "capture": {1: "target_xml"},
                 },
             ],
diff --git a/lldb/test/API/types/AbstractBase.py b/lldb/test/API/types/AbstractBase.py
index 043a5510c62f2..fb1e25254b281 100644
--- a/lldb/test/API/types/AbstractBase.py
+++ b/lldb/test/API/types/AbstractBase.py
@@ -20,7 +20,7 @@ def Msg(var, val, using_frame_variable):
 class GenericTester(TestBase):
     # This is the pattern by design to match the " var = 'value'" output from
     # printf() stmts (see basic_type.cpp).
-    pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$")
+    pattern = re.compile(r" (\*?a[^=]*) = '([^=]*)'$")
 
     # Assert message.
     DATA_TYPE_GROKKED = "Data type from expr parser output is parsed correctly"
@@ -205,7 +205,7 @@ def generic_type_tester(
             #     output: (char) a_array_bounded[0] = 'a'
             #
             try:
-                dt = re.match("^\((.*)\)", output).group(1)
+                dt = re.match(r"^\((.*)\)", output).group(1)
             except:
                 self.fail(self.DATA_TYPE_GROKKED)
 
@@ -284,7 +284,7 @@ def generic_type_expr_tester(
             #     output: (double) $0 = 1100.12
             #
             try:
-                dt = re.match("^\((.*)\) \$[0-9]+ = ", output).group(1)
+                dt = re.match(r"^\((.*)\) \$[0-9]+ = ", output).group(1)
             except:
                 self.fail(self.DATA_TYPE_GROKKED)
 
diff --git a/lldb/utils/lui/sourcewin.py b/lldb/utils/lui/sourcewin.py
index efe3c01f3ebd1..a72dad5985ecd 100644
--- a/lldb/utils/lui/sourcewin.py
+++ b/lldb/utils/lui/sourcewin.py
@@ -210,7 +210,7 @@ def getLocations(event):
                 # inlined frames, so we get the description (which does take
                 # into account inlined functions) and parse it.
                 desc = lldbutil.get_description(location, lldb.eDescriptionLevelFull)
-                match = re.search("at\ ([^:]+):([\d]+)", desc)
+                match = re.search(r"at\ ([^:]+):([\d]+)", desc)
                 try:
                     path = match.group(1)
                     line = int(match.group(2).strip())
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_symbols.py b/llvm/utils/extract_symbols.py
index 10fdf14acd158..726196c28ce1c 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -53,12 +53,12 @@ def nm_get_symbols(tool, lib):
         # The -P flag displays the size field for symbols only when applicable,
         # so the last field is optional. There's no space after the value field,
         # but \s+ match newline also, so \s+\S* will match the optional size field.
-        match = re.match("^(\S+)\s+[BDGRSTuVW]\s+\S+\s+\S*$", line)
+        match = re.match(r"^(\S+)\s+[BDGRSTuVW]\s+\S+\s+\S*$", line)
         if match:
             yield (match.group(1), True)
         # Look for undefined symbols, which have type U and may or may not
         # (depending on which nm is being used) have value and size.
-        match = re.match("^(\S+)\s+U\s+(\S+\s+\S*)?$", line)
+        match = re.match(r"^(\S+)\s+U\s+(\S+\s+\S*)?$", line)
         if match:
             yield (match.group(1), False)
     process.wait()
@@ -71,7 +71,7 @@ def readobj_is_32bit_windows(tool, lib):
         [tool, "--file-header", lib], universal_newlines=True
     )
     for line in output.splitlines():
-        match = re.match("Format: (\S+)", line)
+        match = re.match(r"Format: (\S+)", line)
         if match:
             return match.group(1) == "COFF-i386"
     return False
@@ -100,10 +100,10 @@ def should_keep_microsoft_symbol(symbol, calling_convention_decoration):
     # An anonymous namespace is mangled as ?A(maybe hex number)@. Any symbol
     # that mentions an anonymous namespace can be discarded, as the anonymous
     # namespace doesn't exist outside of that translation unit.
-    elif re.search("\?A(0x\w+)?@", symbol):
+    elif re.search(r"\?A(0x\w+)?@", symbol):
         return None
     # Skip X86GenMnemonicTables functions, they are not exposed from llvm/include/.
-    elif re.match("\?is[A-Z0-9]*@X86 at llvm", symbol):
+    elif re.match(r"\?is[A-Z0-9]*@X86 at llvm", symbol):
         return None
     # Keep mangled llvm:: and clang:: function symbols. How we detect these is a
     # bit of a mess and imprecise, but that avoids having to completely demangle
@@ -169,7 +169,7 @@ class TooComplexName(Exception):
 # (name, rest of string) pair.
 def parse_itanium_name(arg):
     # Check for a normal name
-    match = re.match("(\d+)(.+)", arg)
+    match = re.match(r"(\d+)(.+)", arg)
     if match:
         n = int(match.group(1))
         name = match.group(1) + match.group(2)[:n]
@@ -196,7 +196,7 @@ def skip_itanium_template(arg):
     tmp = arg[1:]
     while tmp:
         # Check for names
-        match = re.match("(\d+)(.+)", tmp)
+        match = re.match(r"(\d+)(.+)", tmp)
         if match:
             n = int(match.group(1))
             tmp = match.group(2)[n:]
@@ -280,19 +280,19 @@ def parse_microsoft_mangling(arg):
         if arg.startswith("@"):
             return components
         # Check for a simple name
-        match = re.match("(\w+)@(.+)", arg)
+        match = re.match(r"(\w+)@(.+)", arg)
         if match:
             components.append((match.group(1), False))
             arg = match.group(2)
             continue
         # Check for a special function name
-        match = re.match("(\?_?\w)(.+)", arg)
+        match = re.match(r"(\?_?\w)(.+)", arg)
         if match:
             components.append((match.group(1), False))
             arg = match.group(2)
             continue
         # Check for a template name
-        match = re.match("\?\$(\w+)@[^@]+@(.+)", arg)
+        match = re.match(r"\?\$(\w+)@[^@]+@(.+)", arg)
         if match:
             components.append((match.group(1), True))
             arg = match.group(2)
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 1766ccb38ba25..be9e3ed4b611f 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -52,9 +52,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
 
 
@@ -483,7 +483,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 2bdabc8c4d74f..c96d780d9faa1 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 line.startswith(" ") == False:
             function = line
-        result = re.search("(call|jmp).*\*", line)
+        result = re.search(r"(call|jmp).*\*", line)
         if result != 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)
diff --git a/mlir/utils/spirv/gen_spirv_dialect.py b/mlir/utils/spirv/gen_spirv_dialect.py
index 426bfca1b4f88..6418c933bfff3 100755
--- a/mlir/utils/spirv/gen_spirv_dialect.py
+++ b/mlir/utils/spirv/gen_spirv_dialect.py
@@ -536,7 +536,7 @@ def gen_instr_coverage_report(path, instructions):
 
     content = content.split(AUTOGEN_OPCODE_SECTION_MARKER)
 
-    existing_opcodes = [k[11:] for k in re.findall("def SPIRV_OC_\w+", content[1])]
+    existing_opcodes = [k[11:] for k in re.findall(r"def SPIRV_OC_\w+", content[1])]
     existing_instructions = list(
         filter(lambda inst: (inst["opname"] in existing_opcodes), instructions)
     )
@@ -594,7 +594,7 @@ def update_td_opcodes(path, instructions, filter_list):
     # Extend opcode list with existing list
     prefix = "def SPIRV_OC_"
     existing_opcodes = [
-        k[len(prefix) :] for k in re.findall(prefix + "\w+", content[1])
+        k[len(prefix) :] for k in re.findall(prefix + r"\w+", content[1])
     ]
     filter_list.extend(existing_opcodes)
     filter_list = list(set(filter_list))
@@ -637,7 +637,7 @@ def update_td_enum_attrs(path, operand_kinds, filter_list):
     assert len(content) == 3
 
     # Extend filter list with existing enum definitions
-    existing_kinds = [k[8:-4] for k in re.findall("def SPIRV_\w+Attr", content[1])]
+    existing_kinds = [k[8:-4] for k in re.findall(r"def SPIRV_\w+Attr", content[1])]
     filter_list.extend(existing_kinds)
 
     capability_mapping = get_capability_mapping(operand_kinds)
@@ -959,12 +959,12 @@ def extract_td_op_info(op_def):
       - A dict containing potential manually specified sections
     """
     # Get opname
-    opname = [o[8:-2] for o in re.findall("def SPIRV_\w+Op", op_def)]
+    opname = [o[8:-2] for o in re.findall(r"def SPIRV_\w+Op", op_def)]
     assert len(opname) == 1, "more than one ops in the same section!"
     opname = opname[0]
 
     # Get instruction category
-    inst_category = [o[4:] for o in re.findall("SPIRV_\w+Op", op_def.split(":", 1)[1])]
+    inst_category = [o[4:] for o in re.findall(r"SPIRV_\w+Op", op_def.split(":", 1)[1])]
     assert len(inst_category) <= 1, "more than one ops in the same section!"
     inst_category = inst_category[0] if len(inst_category) == 1 else "Op"
 
diff --git a/polly/test/update_check.py b/polly/test/update_check.py
index 88d95c247c063..1dd3d3ebf39c0 100644
--- a/polly/test/update_check.py
+++ b/polly/test/update_check.py
@@ -222,7 +222,7 @@ def classyfier2(lines):
         line = i.__next__()
 
 
-replrepl = {"{{": "{{[{][{]}}", "}}": "{{[}][}]}}", "[[": "{{\[\[}}", "]]": "{{\]\]}}"}
+replrepl = {"{{": "{{[{][{]}}", "}}": "{{[}][}]}}", "[[": r"{{\[\[}}", "]]": r"{{\]\]}}"}
 replre = re.compile("|".join(re.escape(k) for k in replrepl.keys()))
 
 
@@ -452,7 +452,7 @@ def main():
     checkre = re.compile(
         r"^\s*\;\s*("
         + "|".join([re.escape(s) for s in checkprefixes])
-        + ")(\-NEXT|\-DAG|\-NOT|\-LABEL|\-SAME)?\s*\:"
+        + r")(\-NEXT|\-DAG|\-NOT|\-LABEL|\-SAME)?\s*\:"
     )
     firstcheckline = None
     firstnoncommentline = None



More information about the lldb-commits mailing list