[Lldb-commits] [lldb] [LLDB] Add array subscription and integer parsing to DIL (PR #138551)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue May 20 01:35:16 PDT 2025
================
@@ -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
More information about the lldb-commits
mailing list