[Lldb-commits] [lldb] [lldb] Add pointer arithmetics for addition and subtraction to DIL (PR #184652)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 13 01:36:44 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);
----------------
Michael137 wrote:
Can you explain the `-` and how we rely on unsigned overflow behaviour here?
https://github.com/llvm/llvm-project/pull/184652
More information about the lldb-commits
mailing list