[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)
Pete Lawrence via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 19 11:40:43 PST 2023
================
@@ -1700,13 +1706,13 @@ ValueObjectSP ValueObject::GetSyntheticChildAtOffset(
return synthetic_child_sp;
if (!can_create)
- return {};
+ return ValueObjectSP();
----------------
PortalPete wrote:
This one is more about consistency because the vast majority of the remaining code (in this file, anyway) use the `ValueObjectSP()` form.
I also have an ulterior motive in that a lot of the changes that (might) come from a later PR will change MANY of these `ValueObjectSP()` instances to `{}` because I convert them to empty optionals, aka `std::optional<ValueObjectSP>` (instead of creating `ValueObjectSP` instances with `nullptr`).
Therefore, when that subsequent PR comes around, I want that changes to reflect all applicable changes as possible. If I leave this line as `return {};`, then the line won't change in the other PR, which reduces the attention that method will get at that time. Not only that, this line would be initializing something completely different, an optional instead of a shared pointer, in that future PR.
I'd rather bring more attention to things that are functionally changing to prevent accidental bugs and/or behavioral changes, specifically because the compiler quietly accepts it either way.
https://github.com/llvm/llvm-project/pull/75865
More information about the lldb-commits
mailing list