[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 09:26:20 PDT 2026
================
@@ -538,6 +538,40 @@ Interpreter::Visit(const UnaryOpNode &node) {
node.GetLocation());
}
+llvm::Expected<lldb::ValueObjectSP>
+Interpreter::PointerOffset(lldb::ValueObjectSP ptr, lldb::ValueObjectSP offset,
+ bool positive, uint32_t location) {
+ if (ptr->GetCompilerType().IsPointerToVoid())
+ return llvm::make_error<DILDiagnosticError>(
+ m_expr, "arithmetic on a pointer to void", location);
+ if (ptr->GetValueAsUnsigned(0) == 0 && offset != 0)
+ return llvm::make_error<DILDiagnosticError>(
+ m_expr, "arithmetic on a nullptr is undefined", location);
+
+ bool success;
+ int64_t offset_int = offset->GetValueAsSigned(0, &success);
----------------
Michael137 wrote:
Might be missing something, but why can't we just rely on `offset->GetValueAsSigned` to give us a positive/negative offset? Why do we need the `positive` argument?
https://github.com/llvm/llvm-project/pull/184652
More information about the lldb-commits
mailing list