[PATCH] D88289: [lldb][NFC] Fix some invalid escapes sequences in Python strings

Raphael Isemann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 03:01:41 PDT 2020


teemperor created this revision.
teemperor added a reviewer: JDevlieghere.
Herald added subscribers: llvm-commits, delcypher.
Herald added a project: LLVM.
teemperor requested review of this revision.

I recently had to run the test suite with a debug Python which got started warning about some invalid
escape sequences in LLDB's Python code. They all attempt to add a backslash by doing a single
backslash instead of a double backslash in a normal string. This seems to work fine for now, but
Python says this behaviour is deprecated, so this patch turns all those strings into raw strings (where
a single backslash is actually a single backslash)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D88289

Files:
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===================================================================
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -471,7 +471,7 @@
         self.config.substitutions.append(
             (' clang ', """\"*** Do not use 'clang' in tests, use '%clang'. ***\""""))
         self.config.substitutions.append(
-            (' clang\+\+ ', """\"*** Do not use 'clang++' in tests, use '%clangxx'. ***\""""))
+            (r' clang\+\+ ', """\"*** Do not use 'clang++' in tests, use '%clangxx'. ***\""""))
         self.config.substitutions.append(
             (' clang-cc ',
              """\"*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***\""""))
@@ -526,11 +526,11 @@
         was_found = ld_lld and lld_link and ld64_lld and wasm_ld
         tool_substitutions = []
         if ld_lld:
-            tool_substitutions.append(ToolSubst('ld\.lld', command=ld_lld))
+            tool_substitutions.append(ToolSubst(r'ld\.lld', command=ld_lld))
         if lld_link:
             tool_substitutions.append(ToolSubst('lld-link', command=lld_link))
         if ld64_lld:
-            tool_substitutions.append(ToolSubst('ld64\.lld', command=ld64_lld))
+            tool_substitutions.append(ToolSubst(r'ld64\.lld', command=ld64_lld))
         if wasm_ld:
             tool_substitutions.append(ToolSubst('wasm-ld', command=wasm_ld))
         self.add_tool_substitutions(tool_substitutions)
Index: llvm/utils/lit/lit/TestRunner.py
===================================================================
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -1105,8 +1105,8 @@
     # "%{/[STpst]:regex_replacement}" should be normalized like "%/[STpst]" but we're
     # also in a regex replacement context of a s@@@ regex.
     def regex_escape(s):
-        s = s.replace('@', '\@')
-        s = s.replace('&', '\&')
+        s = s.replace('@', r'\@')
+        s = s.replace('&', r'\&')
         return s
     substitutions.extend([
             ('%{/s:regex_replacement}',


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88289.294261.patch
Type: text/x-patch
Size: 2068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200925/b2947c01/attachment.bin>


More information about the llvm-commits mailing list