[all-commits] [llvm/llvm-project] a13aa0: [lldb] Fix dwim-print's arrow-operator check to ma...
Yao Qi via All-commits
all-commits at lists.llvm.org
Wed Sep 23 14:12:45 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a13aa07af6d0527a14cdc2e2f3fe4ec3d0ccb362
https://github.com/llvm/llvm-project/commit/a13aa07af6d0527a14cdc2e2f3fe4ec3d0ccb362
Author: Yao Qi <yao_qi at apple.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M lldb/source/Commands/CommandObjectDWIMPrint.cpp
M lldb/test/API/commands/dwim-print/TestDWIMPrint.py
Log Message:
-----------
[lldb] Fix dwim-print's arrow-operator check to match the substring (#225778)
`CommandObjectDWIMPrint::DoExecute` decides whether to try `expr` as a
limited, dot-only frame variable path before falling back to full
expression evaluation. The comment above the check says a variable
path is not attempted if `expr` contains the arrow operator (`->`) or
the subscript operator (`[]`), or a bare `*` or `&`:
```
const bool try_variable_path =
expr.find_first_of("*&->[]") == StringRef::npos;
```
`find_first_of` treats its argument as a set of characters so this also
matches a lone `-` or a lone `>` anywhere in `expr`, not only the
two-character `->` sequence the comment describes.
Fix the check to test for the `->` substring directly with
`StringRef::contains`, keeping `find_first_of` only for the four
characters that are genuinely excluded one at a time (`*`, `&`, `[`,
`]`).
By itself, this widens which expressions attempt the variable-path
fast path (anything with a lone `-` or `>` now does).
Ordinary arithmetic and comparison expressions containing a lone `-`
or `>` now correctly attempt, and correctly fail, the variable-path
fast path before falling through to `expression`, shown here
```
frame #0: liblldb.24.0git.dylib`lldb_private::CommandObjectDWIMPrint::DoExecute(this=<unavailable>, command=<unavailable>, result=<unavailable>) at CommandObjectDWIMPrint.cpp:169:13 [opt]
(lldb) settings set dwim-print-verbosity full
(lldb) dwim-print expr
note: ran `frame variable expr`
(llvm::StringRef) (Data = "1+1", Length = 3)
(lldb) dwim-print expr.Length-1
warning: `this' is not accessible (substituting 0). Couldn't load 'this' because its value couldn't be evaluated
note: ran `expression expr.Length-1`
(size_t) 2
(lldb) dwim-print expr.Length>0
warning: `this' is not accessible (substituting 0). Couldn't load 'this' because its value couldn't be evaluated
note: ran `expression expr.Length>0`
(bool) true
(lldb) dwim-print frame->m_frame_index
warning: `this' is not accessible (substituting 0). Couldn't load 'this' because its value couldn't be evaluated
note: ran `expression frame->m_frame_index`
(uint32_t) 0
```
Add more expressions in `TestDWIMPrint.test_expressions`, to cover
expressions
containing a lone `-` or `>`. Note that these tests can't tell "the
expression is evaluated by DIL but failed" and "expression isn't
evaluated by DIL at all".
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list