[Lldb-commits] [lldb] Report back errors in GetNumChildren() (PR #84265)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 8 09:55:51 PST 2024


adrian-prantl wrote:

> From looking at the code, it seems like there are two clear classes of users, those that need to check the error, and those that, in the error case, 0 is just as good as the error. The latter appears not infrequently as:
> 
> `llvm::expectedToStdOptional(value_sp->GetNumChildren(max)).value_or(0)`
> 
> which is a bit ugly, but also by embedding this everywhere inline it isn't easy to see who is checking errors and who doesn't need to.
> 
> Might be useful to have a GetNumChildrenUnchecked that returns 0 for the error, and use that in place of sprinkling this construct about.

See the latest update in https://github.com/llvm/llvm-project/pull/84219

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


More information about the lldb-commits mailing list