Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (#84219)

Change GetNumChildren()/CalculateNumChildren() methods return
llvm::Expected

This is an NFC change that does not yet add any error handling or change
any code to return any errors.

This is the second big change in the patch series started with
https://github.com/llvm/llvm-project/pull/83501

A follow-up PR will wire up error handling.
This commit is contained in:
Adrian Prantl
2024-03-08 10:39:34 -08:00
committed by GitHub
parent 839a8fecb4
commit 99118c8093
72 changed files with 394 additions and 247 deletions

View File

@@ -126,17 +126,21 @@ ConstString ValueObjectMemory::GetDisplayTypeName() {
return m_compiler_type.GetDisplayTypeName();
}
uint32_t ValueObjectMemory::CalculateNumChildren(uint32_t max) {
llvm::Expected<uint32_t> ValueObjectMemory::CalculateNumChildren(uint32_t max) {
if (m_type_sp) {
auto child_count = m_type_sp->GetNumChildren(true);
return child_count <= max ? child_count : max;
if (!child_count)
return child_count;
return *child_count <= max ? *child_count : max;
}
ExecutionContext exe_ctx(GetExecutionContextRef());
const bool omit_empty_base_classes = true;
auto child_count =
m_compiler_type.GetNumChildren(omit_empty_base_classes, &exe_ctx);
return child_count <= max ? child_count : max;
if (!child_count)
return child_count;
return *child_count <= max ? *child_count : max;
}
std::optional<uint64_t> ValueObjectMemory::GetByteSize() {