[all-commits] [llvm/llvm-project] 3e235a: [lldb] Support alternatives for scope format entri...
Jonas Devlieghere via All-commits
all-commits at lists.llvm.org
Mon May 5 16:11:19 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3e235a7c601d80d6e8a0392ebec859068659ec19
https://github.com/llvm/llvm-project/commit/3e235a7c601d80d6e8a0392ebec859068659ec19
Author: Jonas Devlieghere <jonas at devlieghere.com>
Date: 2025-05-05 (Mon, 05 May 2025)
Changed paths:
M lldb/include/lldb/Core/FormatEntity.h
M lldb/source/Core/FormatEntity.cpp
M lldb/unittests/Core/FormatEntityTest.cpp
Log Message:
-----------
[lldb] Support alternatives for scope format entries (#137751)
This PR implements support for specifying multiple alternatives for
scope format entries. Scopes are used to enclose things that should only
be printed when everything in the scope resolves.
For example, the following scope only resolves if both
`${line.file.basename}` and `${line.number}` resolve. `
```
{ at ${line.file.basename}:${line.number}}
```
However, the current implementation doesn't let you specify what to
print when they don't resolve. This PR adds support for specifying
multiple alternative scopes, which are evaluated left-to-right.
For example:
```
{ at ${line.file.basename}:${line.number}| in ${function.name}| <unknown location>}
```
This will resolve to:
- ` at ${line.file.basename}:${line.number}` if the corresponding
variables resolve.
- Otherwise, this resolves to ` in ${function.name}` if
`${function.name}` resolves.
- Otherwise, this resolves to ` <unknown location>` which always
resolves.
This PR makes the `|` character a special character within a scope, but
allows it to be escaped.
I ended up with this approach because it fit quite nicely in the
existing architecture of the format entries and by limiting the
functionality to scopes, it sidesteps some complexity, like dealing with
recursion.
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