[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 1 16:49:24 PST 2024


JDevlieghere wrote:

> > Why not increase TypeSystem::GetNumChildren to return a size_t instead?
> 
> We could, but even 2^32 seems like an outrageous amount of children to me. What would be a use-case for this? A ValueObject that has the entire address space as synthetic children?
> 
> There is other code that assumes that we can store the result of GetNumChildren() in an int64 and use negative numbers as out-of-band signaling. We could replace that with std::optional of course.

But what's there to gain by limiting it to 32 bits instead of 64? Saying it's unlikely or overkill isn't a very strong argument. I think a possibly better answer to Alex' question is probably: because `SBValue::GetNumChildren` returns a `uint32_t` and we cannot change that, so we'd have to check for overflow at SB API level. I don't feel strongly either way (though if it were me, I'd make everything a `size_t`.) 

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


More information about the lldb-commits mailing list