diff options
Diffstat (limited to 'lldb/source/Expression/IRInterpreter.cpp')
-rw-r--r-- | lldb/source/Expression/IRInterpreter.cpp | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 122d337ddcc..9cb7bc0a29a 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -151,14 +151,12 @@ public: if (constant) { - if (isa<ConstantPointerNull>(constant)) - { - return AssignToMatchType(scalar, 0, value->getType()); - } - else if (const ConstantInt *constant_int = dyn_cast<ConstantInt>(constant)) - { - return AssignToMatchType(scalar, constant_int->getLimitedValue(), value->getType()); - } + APInt value_apint; + + if (!ResolveConstantValue(value_apint, constant)) + return false; + + return AssignToMatchType(scalar, value_apint.getLimitedValue(), value->getType()); } else { @@ -500,6 +498,7 @@ IRInterpreter::CanInterpret (llvm::Module &module, case Instruction::Or: case Instruction::Ret: case Instruction::SDiv: + case Instruction::SExt: case Instruction::Shl: case Instruction::SRem: case Instruction::Store: @@ -821,6 +820,39 @@ IRInterpreter::Interpret (llvm::Module &module, frame.AssignValue(inst, S, module); } break; + case Instruction::SExt: + { + const CastInst *cast_inst = dyn_cast<CastInst>(inst); + + if (!cast_inst) + { + if (log) + log->Printf("getOpcode() returns %s, but instruction is not a BitCastInst", cast_inst->getOpcodeName()); + error.SetErrorToGenericError(); + error.SetErrorString(interpreter_internal_error); + return false; + } + + Value *source = cast_inst->getOperand(0); + + lldb_private::Scalar S; + + if (!frame.EvaluateValue(S, source, module)) + { + if (log) + log->Printf("Couldn't evaluate %s", PrintValue(source).c_str()); + error.SetErrorToGenericError(); + error.SetErrorString(bad_value_error); + return false; + } + + S.MakeSigned(); + + lldb_private::Scalar S_signextend(S.SLongLong()); + + frame.AssignValue(inst, S_signextend, module); + } + break; case Instruction::Br: { const BranchInst *br_inst = dyn_cast<BranchInst>(inst); |