We stopped marking `__lldb_expr` with the function qualifiers of the method LLDB is stopped in ever since `8bdcd522510f923185cdfaec66c4a78d0a0d38c0`. The assumption was that it wasn't ever required for correctness (i.e., LLDB should just always pretend it's in a mutable context). But since function qualifiers affect overloading in C++, this assumption can lead to unexpected expression evaluator behaviour. E.g., if a function is overloaded on qualifiers (`const` vs. `non-const`), the expression evaluator would currently always call the non-CV qualified overload. This patch adds function qualifiers to `$__lldb_class::$__lldb_expr` that resemble the qualifiers of the method that we're stopped in. However, mutating variables or calling arbitrary member functions from CV-qualified methods can be useful/is something users already may be used to. To provide users with the ability to ignore the CV-qualifiers of the current context, we will provide an expression evaluator flag that switches this off in a follow-up patch.
50 lines
891 B
C++
50 lines
891 B
C++
#include <cassert>
|
|
#include <cstdio>
|
|
|
|
struct Foo {
|
|
double bar() { return 5.0; }
|
|
|
|
int bar() const { return 2; }
|
|
|
|
int const_method() const {
|
|
auto x = bar();
|
|
assert(x == 2);
|
|
std::puts("Break: const_method begin");
|
|
|
|
[x] {
|
|
std::puts("Keep on multiple lines...");
|
|
std::puts("Break: const_method no-this lambda");
|
|
}();
|
|
|
|
[x]() mutable {
|
|
std::puts("Keep on multiple lines...");
|
|
std::puts("Break: const_method mutable no-this lambda");
|
|
}();
|
|
|
|
[this, y = x] {
|
|
auto x = bar() + y;
|
|
std::puts("Break: const_method lambda");
|
|
}();
|
|
|
|
[this, y = x]() mutable {
|
|
auto x = bar() + y;
|
|
std::puts("Break: const_method mutable lambda");
|
|
}();
|
|
|
|
return 120;
|
|
}
|
|
|
|
float m_mem = -2.0;
|
|
const float m_const_mem = -3.0;
|
|
};
|
|
|
|
int main() {
|
|
const Foo f;
|
|
f.bar();
|
|
|
|
Foo f2;
|
|
f2.bar();
|
|
|
|
return Foo{}.const_method();
|
|
}
|