Skip to content

Commit 3f295ce

Browse files
committed
Get num children via GetNumChildren(child_idx + 1)
1 parent c7c9a0a commit 3f295ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lldb/source/ValueObject/DILEval.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,13 @@ Interpreter::Visit(const ArraySubscriptNode *node) {
282282
// Check to see if 'base' has a synthetic value; if so, try using that.
283283
uint64_t child_idx = node->GetIndex();
284284
if (lldb::ValueObjectSP synthetic = base->GetSyntheticValue()) {
285-
uint32_t num_children = synthetic->GetNumChildrenIgnoringErrors();
285+
llvm::Expected<uint32_t> num_children =
286+
synthetic->GetNumChildren(child_idx + 1);
287+
if (!num_children)
288+
return llvm::make_error<DILDiagnosticError>(
289+
m_expr, toString(num_children.takeError()), node->GetLocation());
286290
// Verify that the 'index' is not out-of-range for the declared type.
287-
if (child_idx >= num_children) {
291+
if (child_idx >= *num_children) {
288292
std::string message = llvm::formatv(
289293
"array index {0} is not valid for \"({1}) {2}\"", child_idx,
290294
base->GetTypeName().AsCString("<invalid type>"),

0 commit comments

Comments
 (0)