[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)

Augusto Noronha via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 16 11:09:34 PST 2023


augusto2112 wrote:

@DavidSpickett thanks for reminding me. I'll add a comment describing the situation. 

Right now, for conditional breakpoints, we assume that the condition expression is cacheable, since it's being run over and over again in the exact same context. This works for C/C++, but not for Swift, because Swift generics aren't monomorphized (the same problem would happen for other languages where generics aren't monomorphized either, so a more general escape hatch seemed appropriate to me).

To illustrate what I mean, a function such as  the following (in C++ syntax but Swift semantics):

```
template <class T>
void use(T t) {}

// In main
use(5);
use(std::string())
```

Is lowered only once as a truly generic function (unlike C++ which will generate one version per instantiation), so it isn't safe to cache the expression parse, as the argument type may be different in every invocation.

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


More information about the lldb-commits mailing list