Skip to content

Conversation

@cmtice
Copy link
Contributor

@cmtice cmtice commented Sep 3, 2025

PR 156125 removed the escape (backslash) in front of '$' for all quoted strings. It has since been pointed out this should only happen for double-quoted strings. This PR fixes that.

…ble-quoted strings.

PR 156125 removed the escape (backslash) in front of '$' for all
quoted strings. It has since been pointed out this should only happen
for double-quoted strings. This PR fixes that.
@llvmbot
Copy link
Member

llvmbot commented Sep 3, 2025

@llvm/pr-subscribers-testing-tools

Author: None (cmtice)

Changes

PR 156125 removed the escape (backslash) in front of '$' for all quoted strings. It has since been pointed out this should only happen for double-quoted strings. This PR fixes that.


Full diff: https://github.com/llvm/llvm-project/pull/156742.diff

2 Files Affected:

  • (modified) llvm/utils/lit/lit/ShUtil.py (+1-1)
  • (modified) llvm/utils/lit/tests/unit/ShUtil.py (+2)
diff --git a/llvm/utils/lit/lit/ShUtil.py b/llvm/utils/lit/lit/ShUtil.py
index ff151b1e29330..f3778ad23fddf 100644
--- a/llvm/utils/lit/lit/ShUtil.py
+++ b/llvm/utils/lit/lit/ShUtil.py
@@ -117,7 +117,7 @@ def lex_arg_quoted(self, delim):
                 return str
             # LLDB uses "$" at the start of global variable names; it should
             # not be escaped nor dropped.
-            elif c == "\\" and self.look() == "$":
+            elif c == "\\" and self.look() == "$" and delim == '"':
                 c = self.eat()
                 str += c
             elif c == "\\" and delim == '"':
diff --git a/llvm/utils/lit/tests/unit/ShUtil.py b/llvm/utils/lit/tests/unit/ShUtil.py
index 877fc007b8678..2904125b084f2 100644
--- a/llvm/utils/lit/tests/unit/ShUtil.py
+++ b/llvm/utils/lit/tests/unit/ShUtil.py
@@ -30,6 +30,8 @@ def test_quoting(self):
         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):

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the fix!

@cmtice cmtice merged commit e20ce96 into llvm:main Sep 3, 2025
12 checks passed
Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants