diff --git a/llvm/utils/lit/lit/ShUtil.py b/llvm/utils/lit/lit/ShUtil.py index fa13167cad1be..ff151b1e29330 100644 --- a/llvm/utils/lit/lit/ShUtil.py +++ b/llvm/utils/lit/lit/ShUtil.py @@ -115,6 +115,11 @@ def lex_arg_quoted(self, delim): c = self.eat() if c == delim: return str + # LLDB uses "$" at the start of global variable names; it should + # not be escaped nor dropped. + elif c == "\\" and self.look() == "$": + c = self.eat() + str += c elif c == "\\" and delim == '"': # Inside a '"' quoted string, '\\' only escapes the quote # character and backslash, otherwise it is preserved. diff --git a/llvm/utils/lit/tests/unit/ShUtil.py b/llvm/utils/lit/tests/unit/ShUtil.py index c5f2e3b99ae13..877fc007b8678 100644 --- a/llvm/utils/lit/tests/unit/ShUtil.py +++ b/llvm/utils/lit/tests/unit/ShUtil.py @@ -28,7 +28,8 @@ def test_quoting(self): self.assertEqual(self.lex(""" a\\ b a\\\\b """), ["a b", "a\\b"]) self.assertEqual(self.lex(""" "" "" """), ["", ""]) self.assertEqual(self.lex(""" a\\ b """, win32Escapes=True), ["a\\", "b"]) - + self.assertEqual(self.lex('"\\$y = 11"'), ["$y = 11"]) + self.assertEqual(self.lex('"expr \\$y = 11"'), ["expr $y = 11"]) class TestShParse(unittest.TestCase): def parse(self, str):