================
@@ -18,6 +18,22 @@
 
 namespace lldb_private::dil {
 
+static lldb::ValueObjectSP
+ArrayToPointerConversion(lldb::ValueObjectSP valobj,
+                         std::shared_ptr<ExecutionContextScope> ctx) {
+  assert(valobj->IsArrayType() &&
+         "an argument to array-to-pointer conversion must be an array");
+
+  uint64_t addr = valobj->GetLoadAddress();
+  llvm::StringRef name = "result";
+  ExecutionContext exe_ctx;
+  ctx->CalculateExecutionContext(exe_ctx);
+  return ValueObject::CreateValueObjectFromAddress(
+      name, addr, exe_ctx,
+      
valobj->GetCompilerType().GetArrayElementType(ctx.get()).GetPointerType(),
+      /* do_deref */ false);
+}
+
----------------
labath wrote:

Well.. that's why I said it's an interesting question :)

I don't think it should be a language check. It should be plumbed into the type 
system code.. somehow. Currently `ValueObject::Dereference` calls 
`GetCompilerType().GetChildCompilerTypeAtIndex` (which eventually calls into 
the type system). That's kind of a problem because the type system doesn't 
actually know that it's being asked to dereference. Nonetheless, after it 
returns, it does tell you whether the returned child is a dereference of the 
parent (via the `child_is_deref_of_parent` by-ref result).

So, one option that *might* be acceptable (to me, others may disagree) would be 
to call this function on array types as well and then to check whether the 
result has the `child_is_deref_of_parent` flag set (we'd also need to change 
the TypeSystemClang implementation so that it sets the flag for the first 
element of the array).

The alternative would be to create a new function that explicitly tells the 
type system that you're trying to dereference the value, and then it can do 
pretty much anything it wants.


https://github.com/llvm/llvm-project/pull/134428
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to