[Lldb-commits] [lldb] [lldb] Add pointer arithmetics for addition and subtraction to DIL (PR #184652)
Ilia Kuklin via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 13 07:09:45 PDT 2026
================
@@ -602,6 +642,62 @@ llvm::Expected<lldb::ValueObjectSP> Interpreter::EvaluateBinarySubtraction(
if (result_type.IsScalarType())
return EvaluateScalarOp(BinaryOpKind::Sub, lhs, rhs, result_type, location);
+ auto lhs_type = lhs->GetCompilerType();
+ auto rhs_type = rhs->GetCompilerType();
+
+ // "pointer - integer" operation.
+ if (lhs_type.IsPointerType() && rhs_type.IsInteger())
+ return PointerAdd(lhs, -rhs->GetValueAsUnsigned(0), location);
----------------
kuilpd wrote:
I see what you mean. Technically, DIL reports the location of the node that failed, so the user can see the `+` that `failed to read byte-size`. `expr` also just prints the final error and just points with an arrow to where it happened. It's just DIL error doesn't actually point to the location, so it's harder to tell the node.
```
(lldb) expr vptr+1
˄
╰─ error: arithmetic on a pointer to void
(lldb) v vptr+1
<user expression 0>:1:5: arithmetic on a pointer to void
1 | vptr+1
| ^
```
I feel like instead I should look into how to make `DILDiagnosticError` be printed the same way `expr` errors are printed.
https://github.com/llvm/llvm-project/pull/184652
More information about the lldb-commits
mailing list