diff options
| author | Sirraide <aeternalmail@gmail.com> | 2024-05-22 20:15:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-22 20:15:44 +0200 |
| commit | 0370beb230a35f00b7d07c50ab95f8777662a0c6 (patch) | |
| tree | d350968554bb766531b325006a46fb59232ca81f /lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h | |
| parent | 29456e9bcc478d458f40a93d309f992f0a314523 (diff) | |
| download | llvm-0370beb230a35f00b7d07c50ab95f8777662a0c6.zip llvm-0370beb230a35f00b7d07c50ab95f8777662a0c6.tar.gz llvm-0370beb230a35f00b7d07c50ab95f8777662a0c6.tar.bz2 | |
[Clang] Perform derived-to-base conversion on explicit object parameter in lambda (#89828)
Consider this code:
```c++
template <typename... Ts>
struct Overloaded : Ts... { using Ts::operator()...; };
template <typename... Ts>
Overloaded(Ts...) -> Overloaded<Ts...>;
void f() {
int x;
Overloaded o {
[&](this auto& self) {
return &x;
}
};
o();
}
```
To access `x` in the lambda, we need to perform derived-to-base
conversion on `self` (since the type of `self` is not the lambda type,
but rather `Overloaded<(lambda type)>`). We were previously missing this
step, causing us to attempt to load the entire lambda (as the base
class, it would end up being the ‘field’ with index `0` here), which
would then assert later on in codegen.
Moreover, this is only valid in the first place if there is a unique and
publicly accessible cast path from the derived class to the lambda’s
type, so this also adds a check in Sema to diagnose problematic
cases.
This fixes #87210 and fixes #89541.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h')
0 files changed, 0 insertions, 0 deletions
