[llvm] 777df5c - [lldb][NFC] Fix some invalid escapes sequences in Python strings

Raphael Isemann via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 07:09:20 PDT 2020


Author: Raphael Isemann
Date: 2020-10-13T16:04:24+02:00
New Revision: 777df5c93da893819e9586949531ba9aaec97e1f

URL: https://github.com/llvm/llvm-project/commit/777df5c93da893819e9586949531ba9aaec97e1f
DIFF: https://github.com/llvm/llvm-project/commit/777df5c93da893819e9586949531ba9aaec97e1f.diff

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

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)

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D88289

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 643b03fc279a..f826bc91fb3e 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1105,8 +1105,8 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
     # "%{/[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}',

diff  --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index e9fd75e0a5fa..8897deb24cde 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -439,7 +439,7 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True)
         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'. ***\""""))
@@ -494,11 +494,11 @@ def use_lld(self, additional_tool_dirs=[], required=True):
         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)


        


More information about the llvm-commits mailing list