[Lldb-commits] [lldb] [lldb][DWARF] Fix implicit widening bug in DW_OP_plus_uconst (PR #204896)

via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 10 22:08:08 PDT 2026


================
@@ -1534,8 +1534,11 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
 
     case DW_OP_plus_uconst: {
       const uint64_t uconst_value = op->getRawOperand(0);
+      const int byte_size = stack.back().GetScalar().GetByteSize();
       // Implicit conversion from a UINT to a Scalar...
       stack.back().GetScalar() += uconst_value;
+      if (byte_size > 0 && byte_size < 8)
+        stack.back().GetScalar().TruncOrExtendTo(byte_size * 8, false);
----------------
firmiana402 wrote:

This does not preserve the operand's type as required by `DW_OP_plus_uconst`: passing `false` changes every narrow signed operand to unsigned, and a signed 64-bit operand is also promoted to unsigned by `operator+=` but skips this truncation entirely. That affects later signed operations and typed-operand checks.

https://github.com/llvm/llvm-project/pull/204896


More information about the lldb-commits mailing list