================
@@ -272,4 +272,67 @@ 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;
+ const llvm::APInt *index = node->GetIndex();
+
+ Status error;
+ if (base->GetCompilerType().IsReferenceType()) {
+ base = base->Dereference(error);
+ if (error.Fail())
+ return error.ToError();
+ }
+
+ // Check to see if 'base' has a synthetic value; if so, try using that.
+ uint64_t child_idx = index->getZExtValue();
+ if (base->HasSyntheticValue()) {
+ lldb::ValueObjectSP synthetic = base->GetSyntheticValue();
+ if (synthetic && synthetic != base) {
+ uint32_t num_children = synthetic->GetNumChildrenIgnoringErrors();
----------------
kuilpd wrote:
I removed the other 2 of these calls, but this one specifically I couldn't:
`GetChildAtIndex` for a synthetic value calls
`ValueObjectSynthetic::GetChildAtIndex`. That one with `can_create = true`
creates a value regardless of the index and always returns something, like a 0
value for a out of bounds subscript of a vector; and with `can_create = false`
it doesn't create anything, even if index is within bounds and always returns
an error.
https://github.com/llvm/llvm-project/pull/138551
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits