From 715a2a79d7516aa381ff86db247cb3d19c9df650 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Thu, 28 Aug 2025 16:45:34 -0700 Subject: [PATCH 1/4] [lit] Update internal shell lexer to handle LLDB persistent vars. LLDB allows creation of 'persistent' variables, with names that start with '$'. The lit internal shell was escaping the '$', making it '\$', in some CHECK lines, which causes some LLDB tests to fail when using the lit internal shell. This PR fixes that by having the lexer remove the escape on the '$'. --- llvm/utils/lit/lit/ShUtil.py | 5 +++++ 1 file changed, 5 insertions(+) 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. From 369a87ed6af17037a9296e369d61280aa773d8c3 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Tue, 2 Sep 2025 16:53:34 -0700 Subject: [PATCH 2/4] Add test for converting '\$' to '$' in the lexer. --- llvm/utils/lit/tests/unit/ShUtil.py | 1 - 1 file changed, 1 deletion(-) diff --git a/llvm/utils/lit/tests/unit/ShUtil.py b/llvm/utils/lit/tests/unit/ShUtil.py index c5f2e3b99ae13..cee09c4f15f42 100644 --- a/llvm/utils/lit/tests/unit/ShUtil.py +++ b/llvm/utils/lit/tests/unit/ShUtil.py @@ -29,7 +29,6 @@ def test_quoting(self): self.assertEqual(self.lex(""" "" "" """), ["", ""]) self.assertEqual(self.lex(""" a\\ b """, win32Escapes=True), ["a\\", "b"]) - class TestShParse(unittest.TestCase): def parse(self, str): return ShParser(str).parse() From 5e90bdb7bb634c8bf552c7ee64d74837e97b67b4 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Tue, 2 Sep 2025 16:57:58 -0700 Subject: [PATCH 3/4] update lexer test --- llvm/utils/lit/tests/unit/ShUtil.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llvm/utils/lit/tests/unit/ShUtil.py b/llvm/utils/lit/tests/unit/ShUtil.py index cee09c4f15f42..53fa42629a145 100644 --- a/llvm/utils/lit/tests/unit/ShUtil.py +++ b/llvm/utils/lit/tests/unit/ShUtil.py @@ -28,6 +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): From 8c2aeec2a954744bf8f8eea2672548b1b4e7697b Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Tue, 2 Sep 2025 17:05:45 -0700 Subject: [PATCH 4/4] Fix format issue. --- llvm/utils/lit/tests/unit/ShUtil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/utils/lit/tests/unit/ShUtil.py b/llvm/utils/lit/tests/unit/ShUtil.py index 53fa42629a145..877fc007b8678 100644 --- a/llvm/utils/lit/tests/unit/ShUtil.py +++ b/llvm/utils/lit/tests/unit/ShUtil.py @@ -28,8 +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"]) + 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):