[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 7 23:23:43 PDT 2025
labath wrote:
> Trying to add unit tests with this patch. We already have a big test suite that came from `lldb-eval`, and I don't see much reason to rewrite them into Python tests.
> I didn't find an existing way to build the binary for debugging using in-tree compiler and libc++, so had to improvise how to do it in CMake. The compiler options for building I took from Python testing.
This is the reason. Long-term maintainability of the project. We already have (too) many different ways to build test binaries, so you need a very good reason to introduce another method, and frankly, I don't think you have one. If you don't build the test binaries with the same compiler as the rest of the tests, you will expose the test to all of the quirks and bugs of the host compiler, which means that this test will be testing a different thing for every user.
> > With this patch, the biggest question you will have to answer is "why is the implementation of `&` more complicated than `inner_value->AddressOf()`
>
> It's not, the implementation itself is one line, the rest is type and error checking. Same with dereference, only creating an address value first. The node itself is a base for other unary operations in the future.
The fancy reference handling was my main concern, which you've now addressed. I haven't looked at the rest of the code too closely, so it *may* be fine, but in general, I think you shouldn't be looking at the type of the value in the evaluator: You already have the value in hand, so if the expression says you should dereference it, you should just ask the value to dereference itself. If it (and it's type system) knows how to dereference the value, it will give you a result. If not, you'll get an error.
https://github.com/llvm/llvm-project/pull/134428
More information about the lldb-commits
mailing list