================ @@ -272,4 +272,52 @@ Interpreter::Visit(const UnaryOpNode *node) { m_expr, "invalid ast: unexpected binary operator", node->GetLocation()); } +llvm::Expected<lldb::ValueObjectSP> +Interpreter::Visit(const ArraySubscriptNode *node) { + auto lhs_or_err = Evaluate(node->GetBase()); + if (!lhs_or_err) + return lhs_or_err; + lldb::ValueObjectSP base = *lhs_or_err; + + // Check to see if 'base' has a synthetic value; if so, try using that. + uint64_t child_idx = node->GetIndex(); + if (lldb::ValueObjectSP synthetic = base->GetSyntheticValue()) { + llvm::Expected<uint32_t> num_children = + synthetic->GetNumChildren(child_idx + 1); + if (!num_children) + return llvm::make_error<DILDiagnosticError>( + m_expr, toString(num_children.takeError()), node->GetLocation()); + // Verify that the 'index' is not out-of-range for the declared type. ---------------- labath wrote:
technically, this has nothing to do with the type. A formatter can and we have formatters that do that) return different numbers of children for different values of the same type. I think you can just delete the comment as it's kinda obvious.. https://github.com/llvm/llvm-project/pull/138551 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits