[Lldb-commits] [lldb] [llvm] [lldb] Use llvm::DWARFExpression::iterator in DWARFExpression::Evaluate (PR #190556)

Shivam Kunwar via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 7 22:02:53 PDT 2026


================
@@ -1231,36 +1227,36 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     // DW_OP_constu     unsigned LEB128 integer constant
     // DW_OP_consts     signed LEB128 integer constant
     case DW_OP_const1u:
-      stack.push_back(to_generic(opcodes.GetU8(&offset)));
+      stack.push_back(to_generic(op->getRawOperand(0)));
       break;
     case DW_OP_const1s:
-      stack.push_back(to_generic((int8_t)opcodes.GetU8(&offset)));
+      stack.push_back(to_generic((int8_t)op->getRawOperand(0)));
       break;
     case DW_OP_const2u:
-      stack.push_back(to_generic(opcodes.GetU16(&offset)));
+      stack.push_back(to_generic(op->getRawOperand(0)));
       break;
     case DW_OP_const2s:
-      stack.push_back(to_generic((int16_t)opcodes.GetU16(&offset)));
+      stack.push_back(to_generic((int16_t)op->getRawOperand(0)));
       break;
     case DW_OP_const4u:
-      stack.push_back(to_generic(opcodes.GetU32(&offset)));
+      stack.push_back(to_generic(op->getRawOperand(0)));
       break;
     case DW_OP_const4s:
-      stack.push_back(to_generic((int32_t)opcodes.GetU32(&offset)));
+      stack.push_back(to_generic((int32_t)op->getRawOperand(0)));
       break;
     case DW_OP_const8u:
-      stack.push_back(to_generic(opcodes.GetU64(&offset)));
+      stack.push_back(to_generic(op->getRawOperand(0)));
       break;
     case DW_OP_const8s:
-      stack.push_back(to_generic((int64_t)opcodes.GetU64(&offset)));
+      stack.push_back(to_generic((int64_t)op->getRawOperand(0)));
       break;
     // These should also use to_generic, but we can't do that due to a
     // producer-side bug in llvm. See llvm.org/pr48087.
     case DW_OP_constu:
-      stack.push_back(Scalar(opcodes.GetULEB128(&offset)));
+      stack.push_back(Scalar(op->getRawOperand(0)));
       break;
     case DW_OP_consts:
-      stack.push_back(Scalar(opcodes.GetSLEB128(&offset)));
+      stack.push_back(Scalar(op->getRawOperand(0)));
----------------
phyBrackets wrote:

`getRawOperand(0)` returns `uint64_t`. For `DW_OP_consts`, the operand is a signed LEB128. The old code used GetSLEB128 which returned a signed value. With getRawOperand(0), you're getting the raw bits as uint64_t and constructing a scalar from it. Does Scalar(uint64_t) preserve the sign correctly here?

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


More information about the lldb-commits mailing list