[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 20 07:53:00 PDT 2025


labath wrote:

It's close, but it's not the same thing. Notice your arrow points into the error message:
```
(lldb) v externGlobalVar
error: externGlobalVar
       ˄
       ╰─ error: use of undeclared identifier 'externGlobalVar'
```

While for `expr`, it points directly into the command:
```
(lldb) expr 1.0+""
               ˄
               ╰─ error: invalid operands to binary expression ('double' and 'const char[1]')
```

For that, you really need to return the error in a structured form. The string itself is needed as well, as it's used in contexts where it's impossible to show inline diagnostics, or because they have been disabled:
```
And if I disable inline diagnostics I, get the usual clang output:
```
(lldb) set set show-inline-diagnostics false
(lldb) expr 1.0+""
error: <user expression 1>:1:4: invalid operands to binary expression ('double' and 'const char[1]')
    1 | 1.0+""
      | ~~~^~~
```

For this purpose, you could use your original code, or maybe what you have now is fine as well.

https://github.com/llvm/llvm-project/pull/120971


More information about the lldb-commits mailing list