[llvm] 527c8ff - [lit] Update internal shell lexer to handle LLDB persistent vars. (#156125)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 3 08:57:39 PDT 2025
Author: cmtice
Date: 2025-09-03T08:57:34-07:00
New Revision: 527c8ff11e4b05e3502a46a5ad52bb7f0da5ed2a
URL: https://github.com/llvm/llvm-project/commit/527c8ff11e4b05e3502a46a5ad52bb7f0da5ed2a
DIFF: https://github.com/llvm/llvm-project/commit/527c8ff11e4b05e3502a46a5ad52bb7f0da5ed2a.diff
LOG: [lit] Update internal shell lexer to handle LLDB persistent vars. (#156125)
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 an LLDB test,
TestExprWithSideEffectOnConvenienceVar, to fail when using the lit
internal shell.
Further explanation of the failing LLDB test: LLDB convenience variables
start with '$'. The test passes several quoted commands that use and
update convenience variables to lldb as arguments to be run in batch
mode. The tool that packages up the complete string and passes it to the
lit internal shell lexer for lexing inserts a backslash in front of the
'$' before passing the string in for lexing. The lexer was passing this
change along, causing the tests to fail.
This PR fixes the issue by having the lexer remove the newly added
escape on the '$'.
Added:
Modified:
llvm/utils/lit/lit/ShUtil.py
llvm/utils/lit/tests/unit/ShUtil.py
Removed:
################################################################################
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):
More information about the llvm-commits
mailing list