[Lldb-commits] [lldb] 199ac48 - [lldb] Replace ResolveValue() with GetScalar() in DWARFExpression (NFCI) (#185841)

via lldb-commits lldb-commits at lists.llvm.org
Sun Apr 5 01:11:16 PDT 2026


Author: Sergei Barannikov
Date: 2026-04-05T08:11:10Z
New Revision: 199ac48f7373ffb527c84429eacdac9ab68f82ef

URL: https://github.com/llvm/llvm-project/commit/199ac48f7373ffb527c84429eacdac9ab68f82ef
DIFF: https://github.com/llvm/llvm-project/commit/199ac48f7373ffb527c84429eacdac9ab68f82ef.diff

LOG: [lldb] Replace ResolveValue() with GetScalar() in DWARFExpression (NFCI) (#185841)

Value::ResolveValue() only does something if the value has an associated
compiler type, which is never set on values used in DWARF expressions.
Simplify code by inlining the method.

Added: 
    

Modified: 
    lldb/source/Expression/DWARFExpression.cpp
    lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    lldb/source/Target/StackFrame.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 7f59fe827cf25..73f007dab05b2 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1337,7 +1337,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     // value and pushes its absolute value. If the absolute value can not be
     // represented, the result is undefined.
     case DW_OP_abs:
-      if (!stack.back().ResolveValue(exe_ctx).AbsoluteValue()) {
+      if (!stack.back().GetScalar().AbsoluteValue()) {
         return llvm::createStringError(
             "failed to take the absolute value of the first stack item");
       }
@@ -1350,8 +1350,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_and:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) & tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() & tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_div
@@ -1361,18 +1360,18 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     // the result.
     case DW_OP_div: {
       tmp = stack.back();
-      if (tmp.ResolveValue(exe_ctx).IsZero())
+      if (tmp.GetScalar().IsZero())
         return llvm::createStringError("divide by zero");
 
       stack.pop_back();
       Scalar divisor, dividend;
-      divisor = tmp.ResolveValue(exe_ctx);
-      dividend = stack.back().ResolveValue(exe_ctx);
+      divisor = tmp.GetScalar();
+      dividend = stack.back().GetScalar();
       divisor.MakeSigned();
       dividend.MakeSigned();
       stack.back() = dividend / divisor;
 
-      if (!stack.back().ResolveValue(exe_ctx).IsValid())
+      if (!stack.back().GetScalar().IsValid())
         return llvm::createStringError("divide failed");
     } break;
 
@@ -1383,8 +1382,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_minus:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) - tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() - tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_mod
@@ -1395,8 +1393,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_mod:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) % tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() % tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_mul
@@ -1406,15 +1403,14 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_mul:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) * tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() * tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_neg
     // OPERANDS: none
     // DESCRIPTION: pops the top stack entry, and pushes its negation.
     case DW_OP_neg:
-      if (!stack.back().ResolveValue(exe_ctx).UnaryNegate())
+      if (!stack.back().GetScalar().UnaryNegate())
         return llvm::createStringError("unary negate failed");
       break;
 
@@ -1423,7 +1419,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     // DESCRIPTION: pops the top stack entry, and pushes its bitwise
     // complement
     case DW_OP_not:
-      if (!stack.back().ResolveValue(exe_ctx).OnesComplement())
+      if (!stack.back().GetScalar().OnesComplement())
         return llvm::createStringError("logical NOT failed");
       break;
 
@@ -1434,8 +1430,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_or:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) | tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() | tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_plus
@@ -1468,7 +1463,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_shl:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) <<= tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() <<= tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_shr
@@ -1479,8 +1474,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_shr:
       tmp = stack.back();
       stack.pop_back();
-      if (!stack.back().ResolveValue(exe_ctx).ShiftRightLogical(
-              tmp.ResolveValue(exe_ctx)))
+      if (!stack.back().GetScalar().ShiftRightLogical(tmp.GetScalar()))
         return llvm::createStringError("DW_OP_shr failed");
       break;
 
@@ -1493,7 +1487,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_shra:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) >>= tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() >>= tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_xor
@@ -1503,8 +1497,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_xor:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) ^ tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() ^ tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_skip
@@ -1540,7 +1533,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
       stack.pop_back();
       int16_t bra_offset = (int16_t)opcodes.GetU16(&offset);
       Scalar zero(0);
-      if (tmp.ResolveValue(exe_ctx) != zero) {
+      if (tmp.GetScalar() != zero) {
         lldb::offset_t new_offset = offset + bra_offset;
         // New offset can point at the end of the data, in this case we should
         // terminate the DWARF expression evaluation (will happen in the loop
@@ -1565,8 +1558,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_eq:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) == tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() == tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_ge
@@ -1579,8 +1571,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_ge:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) >= tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() >= tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_gt
@@ -1593,8 +1584,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_gt:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) > tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() > tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_le
@@ -1607,8 +1597,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_le:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) <= tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() <= tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_lt
@@ -1621,8 +1610,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_lt:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) < tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() < tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_ne
@@ -1635,8 +1623,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
     case DW_OP_ne:
       tmp = stack.back();
       stack.pop_back();
-      stack.back().ResolveValue(exe_ctx) =
-          stack.back().ResolveValue(exe_ctx) != tmp.ResolveValue(exe_ctx);
+      stack.back().GetScalar() = stack.back().GetScalar() != tmp.GetScalar();
       break;
 
     // OPCODE: DW_OP_litn
@@ -1779,7 +1766,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
         return err;
 
       int64_t breg_offset = opcodes.GetSLEB128(&offset);
-      tmp.ResolveValue(exe_ctx) += (uint64_t)breg_offset;
+      tmp.GetScalar() += (uint64_t)breg_offset;
       tmp.ClearContext();
       stack.push_back(tmp);
       stack.back().SetValueType(Value::ValueType::LoadAddress);
@@ -1797,7 +1784,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
         return err;
 
       int64_t breg_offset = opcodes.GetSLEB128(&offset);
-      tmp.ResolveValue(exe_ctx) += (uint64_t)breg_offset;
+      tmp.GetScalar() += (uint64_t)breg_offset;
       tmp.ClearContext();
       stack.push_back(tmp);
       stack.back().SetValueType(Value::ValueType::LoadAddress);
@@ -2142,7 +2129,7 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
         bit_size = bit_size_sign_or_err->first;
         sign = bit_size_sign_or_err->second;
       }
-      Scalar &top = stack.back().ResolveValue(exe_ctx);
+      Scalar &top = stack.back().GetScalar();
       top.TruncOrExtendTo(bit_size, sign);
       break;
     }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index cb33fc21bfba9..3862ac4a6e763 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -685,7 +685,7 @@ ExtractDataMemberLocation(DWARFDIE const &die, DWARFFormValue const &form_value,
     return {};
   }
 
-  return memberOffset->ResolveValue(nullptr).UInt();
+  return memberOffset->GetScalar().UInt();
 }
 
 static TypePayloadClang GetPtrAuthMofidierPayload(const DWARFDIE &die) {

diff  --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index e04b4e2300635..99302cb6ae63b 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -1174,7 +1174,7 @@ llvm::Error StackFrame::GetFrameBaseValue(Scalar &frame_base) {
       if (!expr_value)
         m_frame_base_error = Status::FromError(expr_value.takeError());
       else
-        m_frame_base = expr_value->ResolveValue(&exe_ctx);
+        m_frame_base = expr_value->GetScalar();
     } else {
       m_frame_base_error =
           Status::FromErrorString("No function in symbol context.");


        


More information about the lldb-commits mailing list