Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: use raw strings for regex #105990

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

negril
Copy link

@negril negril commented Aug 25, 2024

Changed in python version 3.12:
A backslash-character pair that is not a valid escape sequence now generates a
SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.
\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw
strings for regular expression: re.compile(r"\d+.\d+")). In a future Python
version, SyntaxError will eventually be raised, instead of SyntaxWarning.
(Contributed by Victor Stinner in gh-98401.)

Closes: #97815
See-also: https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences

Changed in python version 3.12:
  A backslash-character pair that is not a valid escape sequence now generates a
  SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+\.
  \d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw
  strings for regular expression: re.compile(r"\d+\.\d+")). In a future Python
  version, SyntaxError will eventually be raised, instead of SyntaxWarning.
  (Contributed by Victor Stinner in llvmgh-98401.)

Closes: llvm#97815
See-also: https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
@negril negril requested review from JDevlieghere and a team as code owners August 25, 2024 15:53
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category compiler-rt libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. lld lldb compiler-rt:asan Address sanitizer lld:MachO mlir backend:NVPTX compiler-rt:sanitizer github:workflow labels Aug 25, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 25, 2024

@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-compiler-rt-sanitizer
@llvm/pr-subscribers-backend-nvptx
@llvm/pr-subscribers-github-workflow
@llvm/pr-subscribers-lldb

@llvm/pr-subscribers-clang

Author: Paul Zander (negril)

Changes

Changed in python version 3.12:
A backslash-character pair that is not a valid escape sequence now generates a
SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.
\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw
strings for regular expression: re.compile(r"\d+.\d+")). In a future Python
version, SyntaxError will eventually be raised, instead of SyntaxWarning.
(Contributed by Victor Stinner in gh-98401.)

Closes: #97815
See-also: https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences


Patch is 123.19 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/105990.diff

98 Files Affected:

  • (modified) .github/workflows/version-check.py (+1-1)
  • (modified) clang/docs/tools/dump_ast_matchers.py (+2-2)
  • (modified) clang/test/Analysis/check-analyzer-fixit.py (+1-1)
  • (modified) compiler-rt/lib/asan/scripts/asan_symbolize.py (+2-2)
  • (modified) cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py (+2-2)
  • (modified) cross-project-tests/lit.cfg.py (+3-3)
  • (modified) libcxx/utils/synchronize_csv_status_files.py (+1-1)
  • (modified) lld/test/MachO/tools/validate-unwind-info.py (+1-1)
  • (modified) lld/utils/benchmark.py (+1-1)
  • (modified) lldb/examples/python/crashlog.py (+4-4)
  • (modified) lldb/examples/python/delta.py (+1-1)
  • (modified) lldb/examples/python/gdbremote.py (+3-3)
  • (modified) lldb/examples/python/jump.py (+3-3)
  • (modified) lldb/examples/python/performance.py (+1-1)
  • (modified) lldb/examples/python/symbolication.py (+3-3)
  • (modified) lldb/packages/Python/lldbsuite/test/lldbpexpect.py (+1-1)
  • (modified) lldb/packages/Python/lldbsuite/test/test_runner/process_control.py (+1-1)
  • (modified) lldb/test/API/commands/command/backticks/TestBackticksInAlias.py (+2-2)
  • (modified) lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py (+1-1)
  • (modified) lldb/test/API/commands/expression/test/TestExprs.py (+1-1)
  • (modified) lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py (+1-1)
  • (modified) lldb/test/API/commands/help/TestHelp.py (+3-3)
  • (modified) lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py (+1-1)
  • (modified) lldb/test/API/commands/register/register/TestRegistersUnavailable.py (+2-2)
  • (modified) lldb/test/API/commands/register/register/register_command/TestRegisters.py (+3-3)
  • (modified) lldb/test/API/commands/settings/TestSettings.py (+6-6)
  • (modified) lldb/test/API/commands/target/basic/TestTargetCommand.py (+1-1)
  • (modified) lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py (+8-8)
  • (modified) lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py (+8-8)
  • (modified) lldb/test/API/commands/trace/TestTraceDumpInfo.py (+1-1)
  • (modified) lldb/test/API/commands/trace/TestTraceTSC.py (+5-5)
  • (modified) lldb/test/API/driver/quit_speed/TestQuitWithProcess.py (+1-1)
  • (modified) lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py (+1-1)
  • (modified) lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (+3-3)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (+3-3)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py (+8-8)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py (+11-11)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py (+2-2)
  • (modified) lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py (+5-5)
  • (modified) lldb/test/API/functionalities/memory-region/TestMemoryRegion.py (+1-1)
  • (modified) lldb/test/API/functionalities/target_var/TestTargetVar.py (+1-1)
  • (modified) lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py (+1-1)
  • (modified) lldb/test/API/lang/c/enum_types/TestEnumTypes.py (+2-2)
  • (modified) lldb/test/API/lang/c/function_types/TestFunctionTypes.py (+1-1)
  • (modified) lldb/test/API/lang/c/register_variables/TestRegisterVariables.py (+1-1)
  • (modified) lldb/test/API/lang/c/set_values/TestSetValues.py (+2-2)
  • (modified) lldb/test/API/lang/c/strings/TestCStrings.py (+1-1)
  • (modified) lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py (+4-4)
  • (modified) lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py (+4-4)
  • (modified) lldb/test/API/lang/cpp/class_static/TestStaticVariables.py (+2-2)
  • (modified) lldb/test/API/lang/cpp/class_types/TestClassTypes.py (+1-1)
  • (modified) lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py (+1-1)
  • (modified) lldb/test/API/lang/cpp/namespace/TestNamespace.py (+2-2)
  • (modified) lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py (+2-2)
  • (modified) lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py (+1-1)
  • (modified) lldb/test/API/lang/mixed/TestMixedLanguages.py (+2-2)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethods.py (+1-1)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py (+5-5)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py (+1-1)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py (+5-5)
  • (modified) lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py (+1-1)
  • (modified) lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py (+2-2)
  • (modified) lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py (+22-22)
  • (modified) lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py (+85-85)
  • (modified) lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py (+3-3)
  • (modified) lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py (+2-2)
  • (modified) lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py (+1-1)
  • (modified) lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py (+1-1)
  • (modified) lldb/test/API/macosx/lc-note/kern-ver-str/TestKernVerStrLCNOTE.py (+1-1)
  • (modified) lldb/test/API/macosx/lc-note/multiple-binary-corefile/TestMultipleBinaryCorefile.py (+1-1)
  • (modified) lldb/test/API/macosx/simulator/TestSimulatorPlatform.py (+1-1)
  • (modified) lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py (+1-1)
  • (modified) lldb/test/API/python_api/address_range/TestAddressRange.py (+3-3)
  • (modified) lldb/test/API/python_api/target-arch-from-module/TestTargetArchFromModule.py (+1-1)
  • (modified) lldb/test/API/source-manager/TestSourceManager.py (+1-1)
  • (modified) lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py (+3-3)
  • (modified) lldb/test/API/tools/lldb-server/TestPtyServer.py (+1-1)
  • (modified) lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py (+1-1)
  • (modified) lldb/test/API/types/AbstractBase.py (+3-3)
  • (modified) lldb/utils/lui/sourcewin.py (+1-1)
  • (modified) llvm/test/CodeGen/NVPTX/wmma.py (+1-1)
  • (modified) llvm/tools/opt-viewer/opt-viewer.py (+1-1)
  • (modified) llvm/utils/DSAclean.py (+1-1)
  • (modified) llvm/utils/DSAextract.py (+2-2)
  • (modified) llvm/utils/add_argument_names.py (+1-1)
  • (modified) llvm/utils/convert-constraint-log-to-z3.py (+1-1)
  • (modified) llvm/utils/extract_symbols.py (+12-12)
  • (modified) llvm/utils/extract_vplan.py (+1-1)
  • (modified) llvm/utils/git/github-automation.py (+3-3)
  • (modified) llvm/utils/indirect_calls.py (+1-1)
  • (modified) llvm/utils/relative_lines.py (+1-1)
  • (modified) llvm/utils/update_test_prefix.py (+5-5)
  • (modified) mlir/utils/spirv/gen_spirv_dialect.py (+5-5)
  • (modified) polly/test/update_check.py (+2-2)
diff --git a/.github/workflows/version-check.py b/.github/workflows/version-check.py
index f75fd50300881b..ed41ef4e1b16b0 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/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py
index 705ff0d4d40985..90a44dbdf5b573 100755
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -101,7 +101,7 @@ 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)
 
@@ -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 b616255de89b0c..efed0afc626b95 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(r"// *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 b08769614aeb18..058a1614b55e6a 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 29d7867e808673..4fa5db1b503cdc 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 = [r'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 9935fe6a199da8..c24f0f93e656f1 100644
--- a/cross-project-tests/lit.cfg.py
+++ b/cross-project-tests/lit.cfg.py
@@ -223,7 +223,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:
@@ -247,7 +247,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
@@ -261,7 +261,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/utils/synchronize_csv_status_files.py b/libcxx/utils/synchronize_csv_status_files.py
index 5ff718e5a8f916..26f662b521be87 100755
--- a/libcxx/utils/synchronize_csv_status_files.py
+++ b/libcxx/utils/synchronize_csv_status_files.py
@@ -284,7 +284,7 @@ def sync_csv(rows: List[Tuple], from_github: List[PaperInfo]) -> List[Tuple]:
             results.append(gh.for_printing())
             continue
         elif paper.status != gh.status:
-            print(f"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}")
+            print(rf"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}")
         results.append(row)
 
     return results
diff --git a/lld/test/MachO/tools/validate-unwind-info.py b/lld/test/MachO/tools/validate-unwind-info.py
index ac49f1ecb58899..1cc82f82792731 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 a07d5ecc69417c..7202e07ec438d2 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 368437ed63e46b..bacba1b453fab6 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -296,7 +296,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
@@ -501,7 +501,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):
@@ -925,7 +925,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>.+)
@@ -1095,7 +1095,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 eeb3c177cfa901..f847b95ab119f1 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 40ee15853fdb21..df81353b268c7b 100755
--- a/lldb/examples/python/gdbremote.py
+++ b/lldb/examples/python/gdbremote.py
@@ -1537,13 +1537,13 @@ 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_checksum_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(r".*#[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 e086df5fd15282..8d52bd9af43f6d 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 869a0b061cf852..b86b5a52522e09 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 f6dcc8b9a79437..b16745ee963c9f 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 998a080565b6b3..4a334fb54b28cc 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 rb"\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 07c17993bc8786..8ab219a92d99dd 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 c31a08ac00182f..2cb8d225d6d07b 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 d27f07717affb8..a82141a0792f25 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 41faf07f8cb44a..17fd952130ee72 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 3bb45521747d82..69aa674f6ae5d0 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 f0f5bcb3218011..d9fdb8e7d54ba7 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\)."
+                r"--show-tags\n\s+Include memory tags in output "
+                r"\(does not apply to binary output\)."
             ],
         )
         self.expect(
             "help memory find",
-            patterns=["--show-tags\n\s+Include memory tags in output."],
+            patterns=[r"--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 fcf61c9775c635..a7f8b38649b22f 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("pr...
[truncated]

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 25, 2024

@llvm/pr-subscribers-libcxx

Author: Paul Zander (negril)

Changes

Changed in python version 3.12:
A backslash-character pair that is not a valid escape sequence now generates a
SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.
\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw
strings for regular expression: re.compile(r"\d+.\d+")). In a future Python
version, SyntaxError will eventually be raised, instead of SyntaxWarning.
(Contributed by Victor Stinner in gh-98401.)

Closes: #97815
See-also: https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences


Patch is 123.19 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/105990.diff

98 Files Affected:

  • (modified) .github/workflows/version-check.py (+1-1)
  • (modified) clang/docs/tools/dump_ast_matchers.py (+2-2)
  • (modified) clang/test/Analysis/check-analyzer-fixit.py (+1-1)
  • (modified) compiler-rt/lib/asan/scripts/asan_symbolize.py (+2-2)
  • (modified) cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py (+2-2)
  • (modified) cross-project-tests/lit.cfg.py (+3-3)
  • (modified) libcxx/utils/synchronize_csv_status_files.py (+1-1)
  • (modified) lld/test/MachO/tools/validate-unwind-info.py (+1-1)
  • (modified) lld/utils/benchmark.py (+1-1)
  • (modified) lldb/examples/python/crashlog.py (+4-4)
  • (modified) lldb/examples/python/delta.py (+1-1)
  • (modified) lldb/examples/python/gdbremote.py (+3-3)
  • (modified) lldb/examples/python/jump.py (+3-3)
  • (modified) lldb/examples/python/performance.py (+1-1)
  • (modified) lldb/examples/python/symbolication.py (+3-3)
  • (modified) lldb/packages/Python/lldbsuite/test/lldbpexpect.py (+1-1)
  • (modified) lldb/packages/Python/lldbsuite/test/test_runner/process_control.py (+1-1)
  • (modified) lldb/test/API/commands/command/backticks/TestBackticksInAlias.py (+2-2)
  • (modified) lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py (+1-1)
  • (modified) lldb/test/API/commands/expression/test/TestExprs.py (+1-1)
  • (modified) lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py (+1-1)
  • (modified) lldb/test/API/commands/help/TestHelp.py (+3-3)
  • (modified) lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py (+1-1)
  • (modified) lldb/test/API/commands/register/register/TestRegistersUnavailable.py (+2-2)
  • (modified) lldb/test/API/commands/register/register/register_command/TestRegisters.py (+3-3)
  • (modified) lldb/test/API/commands/settings/TestSettings.py (+6-6)
  • (modified) lldb/test/API/commands/target/basic/TestTargetCommand.py (+1-1)
  • (modified) lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py (+8-8)
  • (modified) lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py (+8-8)
  • (modified) lldb/test/API/commands/trace/TestTraceDumpInfo.py (+1-1)
  • (modified) lldb/test/API/commands/trace/TestTraceTSC.py (+5-5)
  • (modified) lldb/test/API/driver/quit_speed/TestQuitWithProcess.py (+1-1)
  • (modified) lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py (+1-1)
  • (modified) lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (+3-3)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (+3-3)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py (+8-8)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py (+11-11)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py (+2-2)
  • (modified) lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py (+5-5)
  • (modified) lldb/test/API/functionalities/memory-region/TestMemoryRegion.py (+1-1)
  • (modified) lldb/test/API/functionalities/target_var/TestTargetVar.py (+1-1)
  • (modified) lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py (+1-1)
  • (modified) lldb/test/API/lang/c/enum_types/TestEnumTypes.py (+2-2)
  • (modified) lldb/test/API/lang/c/function_types/TestFunctionTypes.py (+1-1)
  • (modified) lldb/test/API/lang/c/register_variables/TestRegisterVariables.py (+1-1)
  • (modified) lldb/test/API/lang/c/set_values/TestSetValues.py (+2-2)
  • (modified) lldb/test/API/lang/c/strings/TestCStrings.py (+1-1)
  • (modified) lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py (+4-4)
  • (modified) lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py (+4-4)
  • (modified) lldb/test/API/lang/cpp/class_static/TestStaticVariables.py (+2-2)
  • (modified) lldb/test/API/lang/cpp/class_types/TestClassTypes.py (+1-1)
  • (modified) lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py (+1-1)
  • (modified) lldb/test/API/lang/cpp/namespace/TestNamespace.py (+2-2)
  • (modified) lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py (+2-2)
  • (modified) lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py (+1-1)
  • (modified) lldb/test/API/lang/mixed/TestMixedLanguages.py (+2-2)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethods.py (+1-1)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py (+5-5)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py (+1-1)
  • (modified) lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py (+5-5)
  • (modified) lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py (+1-1)
  • (modified) lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py (+2-2)
  • (modified) lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py (+22-22)
  • (modified) lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py (+85-85)
  • (modified) lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py (+3-3)
  • (modified) lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py (+2-2)
  • (modified) lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py (+1-1)
  • (modified) lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py (+1-1)
  • (modified) lldb/test/API/macosx/lc-note/kern-ver-str/TestKernVerStrLCNOTE.py (+1-1)
  • (modified) lldb/test/API/macosx/lc-note/multiple-binary-corefile/TestMultipleBinaryCorefile.py (+1-1)
  • (modified) lldb/test/API/macosx/simulator/TestSimulatorPlatform.py (+1-1)
  • (modified) lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py (+1-1)
  • (modified) lldb/test/API/python_api/address_range/TestAddressRange.py (+3-3)
  • (modified) lldb/test/API/python_api/target-arch-from-module/TestTargetArchFromModule.py (+1-1)
  • (modified) lldb/test/API/source-manager/TestSourceManager.py (+1-1)
  • (modified) lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py (+3-3)
  • (modified) lldb/test/API/tools/lldb-server/TestPtyServer.py (+1-1)
  • (modified) lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py (+1-1)
  • (modified) lldb/test/API/types/AbstractBase.py (+3-3)
  • (modified) lldb/utils/lui/sourcewin.py (+1-1)
  • (modified) llvm/test/CodeGen/NVPTX/wmma.py (+1-1)
  • (modified) llvm/tools/opt-viewer/opt-viewer.py (+1-1)
  • (modified) llvm/utils/DSAclean.py (+1-1)
  • (modified) llvm/utils/DSAextract.py (+2-2)
  • (modified) llvm/utils/add_argument_names.py (+1-1)
  • (modified) llvm/utils/convert-constraint-log-to-z3.py (+1-1)
  • (modified) llvm/utils/extract_symbols.py (+12-12)
  • (modified) llvm/utils/extract_vplan.py (+1-1)
  • (modified) llvm/utils/git/github-automation.py (+3-3)
  • (modified) llvm/utils/indirect_calls.py (+1-1)
  • (modified) llvm/utils/relative_lines.py (+1-1)
  • (modified) llvm/utils/update_test_prefix.py (+5-5)
  • (modified) mlir/utils/spirv/gen_spirv_dialect.py (+5-5)
  • (modified) polly/test/update_check.py (+2-2)
diff --git a/.github/workflows/version-check.py b/.github/workflows/version-check.py
index f75fd50300881b..ed41ef4e1b16b0 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/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py
index 705ff0d4d40985..90a44dbdf5b573 100755
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -101,7 +101,7 @@ 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)
 
@@ -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 b616255de89b0c..efed0afc626b95 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(r"// *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 b08769614aeb18..058a1614b55e6a 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 29d7867e808673..4fa5db1b503cdc 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 = [r'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 9935fe6a199da8..c24f0f93e656f1 100644
--- a/cross-project-tests/lit.cfg.py
+++ b/cross-project-tests/lit.cfg.py
@@ -223,7 +223,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:
@@ -247,7 +247,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
@@ -261,7 +261,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/utils/synchronize_csv_status_files.py b/libcxx/utils/synchronize_csv_status_files.py
index 5ff718e5a8f916..26f662b521be87 100755
--- a/libcxx/utils/synchronize_csv_status_files.py
+++ b/libcxx/utils/synchronize_csv_status_files.py
@@ -284,7 +284,7 @@ def sync_csv(rows: List[Tuple], from_github: List[PaperInfo]) -> List[Tuple]:
             results.append(gh.for_printing())
             continue
         elif paper.status != gh.status:
-            print(f"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}")
+            print(rf"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}")
         results.append(row)
 
     return results
diff --git a/lld/test/MachO/tools/validate-unwind-info.py b/lld/test/MachO/tools/validate-unwind-info.py
index ac49f1ecb58899..1cc82f82792731 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 a07d5ecc69417c..7202e07ec438d2 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 368437ed63e46b..bacba1b453fab6 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -296,7 +296,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
@@ -501,7 +501,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):
@@ -925,7 +925,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>.+)
@@ -1095,7 +1095,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 eeb3c177cfa901..f847b95ab119f1 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 40ee15853fdb21..df81353b268c7b 100755
--- a/lldb/examples/python/gdbremote.py
+++ b/lldb/examples/python/gdbremote.py
@@ -1537,13 +1537,13 @@ 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_checksum_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(r".*#[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 e086df5fd15282..8d52bd9af43f6d 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 869a0b061cf852..b86b5a52522e09 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 f6dcc8b9a79437..b16745ee963c9f 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 998a080565b6b3..4a334fb54b28cc 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 rb"\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 07c17993bc8786..8ab219a92d99dd 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 c31a08ac00182f..2cb8d225d6d07b 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 d27f07717affb8..a82141a0792f25 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 41faf07f8cb44a..17fd952130ee72 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 3bb45521747d82..69aa674f6ae5d0 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 f0f5bcb3218011..d9fdb8e7d54ba7 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\)."
+                r"--show-tags\n\s+Include memory tags in output "
+                r"\(does not apply to binary output\)."
             ],
         )
         self.expect(
             "help memory find",
-            patterns=["--show-tags\n\s+Include memory tags in output."],
+            patterns=[r"--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 fcf61c9775c635..a7f8b38649b22f 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("pr...
[truncated]

@tru
Copy link
Collaborator

tru commented Aug 26, 2024

This was suggested in #91856 and the suggestion there was that we need to split it up per sub-project which is something @e-kwsm has been doing: https://github.com/llvm/llvm-project/pulls/e-kwsm so I don't think this one is needed.

@@ -284,7 +284,7 @@ def sync_csv(rows: List[Tuple], from_github: List[PaperInfo]) -> List[Tuple]:
results.append(gh.for_printing())
continue
elif paper.status != gh.status:
print(f"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}")
print(rf"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a regex -- this change looks wrong.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences. The \n and \G are interpreted as an escape sequence. Hence necessitates the change.

Copy link
Member

@thesamesam thesamesam Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe @negril is right.

Note that https://docs.python.org/3/whatsnew/3.12.html#other-language-changes doesn't say it's exclusive to regex:

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)

EDIT: In fact, looking at python/cpython#98401, general format strings for print are used as an example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look intended to me though. The \G should probably have been a \nG.

Copy link
Author

@negril negril Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can be fixed if you want me to?

Copy link
Member

@ldionne ldionne Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah that's the issue. The \G is unintended. I'll fix this right now.

b2dd840

Copy link

⚠️ Python code formatter, darker found issues in your code. ⚠️

You can test this locally with the following command:
darker --check --diff -r 1193f7d6487d2d94009f8d8d27da3907136482b9...e9ffeeaf7a0bf70c58a04315e451ba4553765586 .github/workflows/version-check.py clang/docs/tools/dump_ast_matchers.py clang/test/Analysis/check-analyzer-fixit.py compiler-rt/lib/asan/scripts/asan_symbolize.py cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py cross-project-tests/lit.cfg.py libcxx/utils/synchronize_csv_status_files.py lld/test/MachO/tools/validate-unwind-info.py lld/utils/benchmark.py lldb/examples/python/crashlog.py lldb/examples/python/delta.py lldb/examples/python/gdbremote.py lldb/examples/python/jump.py lldb/examples/python/performance.py lldb/examples/python/symbolication.py lldb/packages/Python/lldbsuite/test/lldbpexpect.py lldb/packages/Python/lldbsuite/test/test_runner/process_control.py lldb/test/API/commands/command/backticks/TestBackticksInAlias.py lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py lldb/test/API/commands/expression/test/TestExprs.py lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py lldb/test/API/commands/help/TestHelp.py lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py lldb/test/API/commands/register/register/TestRegistersUnavailable.py lldb/test/API/commands/register/register/register_command/TestRegisters.py lldb/test/API/commands/settings/TestSettings.py lldb/test/API/commands/target/basic/TestTargetCommand.py lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py lldb/test/API/commands/trace/TestTraceDumpInfo.py lldb/test/API/commands/trace/TestTraceTSC.py lldb/test/API/driver/quit_speed/TestQuitWithProcess.py lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py lldb/test/API/functionalities/memory-region/TestMemoryRegion.py lldb/test/API/functionalities/target_var/TestTargetVar.py lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py lldb/test/API/lang/c/enum_types/TestEnumTypes.py lldb/test/API/lang/c/function_types/TestFunctionTypes.py lldb/test/API/lang/c/register_variables/TestRegisterVariables.py lldb/test/API/lang/c/set_values/TestSetValues.py lldb/test/API/lang/c/strings/TestCStrings.py lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py lldb/test/API/lang/cpp/char1632_t/TestChar1632T.py lldb/test/API/lang/cpp/class_static/TestStaticVariables.py lldb/test/API/lang/cpp/class_types/TestClassTypes.py lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py lldb/test/API/lang/cpp/namespace/TestNamespace.py lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py lldb/test/API/lang/mixed/TestMixedLanguages.py lldb/test/API/lang/objc/foundation/TestObjCMethods.py lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py lldb/test/API/macosx/lc-note/kern-ver-str/TestKernVerStrLCNOTE.py lldb/test/API/macosx/lc-note/multiple-binary-corefile/TestMultipleBinaryCorefile.py lldb/test/API/macosx/simulator/TestSimulatorPlatform.py lldb/test/API/macosx/skinny-corefile/TestSkinnyCorefile.py lldb/test/API/python_api/address_range/TestAddressRange.py lldb/test/API/python_api/target-arch-from-module/TestTargetArchFromModule.py lldb/test/API/source-manager/TestSourceManager.py lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py lldb/test/API/tools/lldb-server/TestPtyServer.py lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py lldb/test/API/types/AbstractBase.py lldb/utils/lui/sourcewin.py llvm/test/CodeGen/NVPTX/wmma.py llvm/tools/opt-viewer/opt-viewer.py llvm/utils/DSAclean.py llvm/utils/DSAextract.py llvm/utils/add_argument_names.py llvm/utils/convert-constraint-log-to-z3.py llvm/utils/extract_symbols.py llvm/utils/extract_vplan.py llvm/utils/git/github-automation.py llvm/utils/indirect_calls.py llvm/utils/relative_lines.py llvm/utils/update_test_prefix.py mlir/utils/spirv/gen_spirv_dialect.py polly/test/update_check.py
View the diff from darker here.
--- libcxx/utils/synchronize_csv_status_files.py	2024-08-25 15:52:29.000000 +0000
+++ libcxx/utils/synchronize_csv_status_files.py	2024-08-26 16:05:28.875052 +0000
@@ -282,11 +282,13 @@
         # something must be wrong.
         if paper.status < gh.status:
             results.append(gh.for_printing())
             continue
         elif paper.status != gh.status:
-            print(rf"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}")
+            print(
+                rf"We found a CSV row and a Github issue with different statuses:\nrow: {row}\Github issue: {gh}"
+            )
         results.append(row)
 
     return results
 
 CSV_FILES_TO_SYNC = [
--- lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py	2024-08-25 15:52:29.000000 +0000
+++ lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py	2024-08-26 16:05:31.141160 +0000
@@ -102,11 +102,13 @@
             'frame variable int_array --summary-string "${*var[0-1]}"', substrs=["3"]
         )
 
         self.runCmd("type summary clear")
 
-        self.runCmd(r'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"])
 
         self.runCmd('type summary add --summary-string "${var[0-1]}" "int[]"')
 
--- lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py	2024-08-25 15:52:29.000000 +0000
+++ lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py	2024-08-26 16:05:32.453203 +0000
@@ -522,11 +522,13 @@
         )
 
         # 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=[r"0x[0-9A-Fa-f]+f0: 0x0+ \(tag: 0xf\)\n" "0x[0-9A-Fa-f]+00: 0x0+"],
+            patterns=[
+                r"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
         # parts of this result. Where we read from before the tagged page to after it.
         # Add --force here because we're reading just over 4k.
--- lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py	2024-08-25 15:52:29.000000 +0000
+++ lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py	2024-08-26 16:05:32.513656 +0000
@@ -37,11 +37,12 @@
             substrs=["stopped", "stop reason = breakpoint"],
         )
 
         # Despite the non address bits we should find a region
         self.expect(
-            "memory region the_page", patterns=[r"\[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
         # the command until the last region.
         self.runCmd("memory region 0")
@@ -66,7 +67,8 @@
             self.runCmd("memory region")
 
         # This should not error, since the user supplied address overrides
         # the previous end address.
         self.expect(
-            "memory region the_page", patterns=[r"\[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"],
         )
--- polly/test/update_check.py	2024-08-25 15:52:29.000000 +0000
+++ polly/test/update_check.py	2024-08-26 16:05:34.430205 +0000
@@ -220,11 +220,16 @@
         else:
             yield set()
         line = i.__next__()
 
 
-replrepl = {"{{": "{{[{][{]}}", "}}": "{{[}][}]}}", "[[": r"{{\[\[}}", "]]": r"{{\]\]}}"}
+replrepl = {
+    "{{": "{{[{][{]}}",
+    "}}": "{{[}][}]}}",
+    "[[": r"{{\[\[}}",
+    "]]": r"{{\]\]}}",
+}
 replre = re.compile("|".join(re.escape(k) for k in replrepl.keys()))
 
 
 def main():
     parser = argparse.ArgumentParser(description="Update CHECK lines")

@negril
Copy link
Author

negril commented Aug 26, 2024

This was suggested in #91856 and the suggestion there was that we need to split it up per sub-project which is something @e-kwsm has been doing: https://github.com/llvm/llvm-project/pulls/e-kwsm so I don't think this one is needed.

That PR is 3 months old? What are the odds or the timeline of it getting merged?

@boomanaiden154
Copy link
Contributor

That PR is 3 months old? What are the odds or the timeline of it getting merged?

Probably whenever the author gets back to reviewers. There might be a couple rounds of review before things get pushed through, but patches for two subprojects have landed already.

The author doesn't seem particularly responsive though. If you want to pick it up, creating per-project PRs like done in the original PR linked, that would probably be best.

@negril
Copy link
Author

negril commented Aug 26, 2024

That PR is 3 months old? What are the odds or the timeline of it getting merged?

Probably whenever the author gets back to reviewers. There might be a couple rounds of review before things get pushed through, but patches for two subprojects have landed already.

The author doesn't seem particularly responsive though. If you want to pick it up, creating per-project PRs like done in the original PR linked, that would probably be best.

Sounds good.

@medismailben
Copy link
Member

Nice! Please make sure to run the python formatter (darker) before landing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:NVPTX clang Clang issues not falling into any other category compiler-rt:asan Address sanitizer compiler-rt:sanitizer compiler-rt github:workflow libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. lld:MachO lld lldb mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asan_symbolize.py: SyntaxWarning reported by Python 3.12 re. invalid escape sequences
8 participants