[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
Mon Mar 16 05:48:28 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:
Why can't we just rely on the `offset` `ValueObject` to carry information about its signedness? If we just do `offset->GetValueAsSigned`, why is that always positive at the moment? Do we drop the signedness somewhere ealier, so we have to restore it here?
https://github.com/llvm/llvm-project/pull/184652
More information about the lldb-commits
mailing list