diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -800,15 +800,7 @@ } } break; case Instruction::Alloca: { - const AllocaInst *alloca_inst = dyn_cast(inst); - - if (!alloca_inst) { - LLDB_LOGF(log, "getOpcode() returns Alloca, but instruction is not an " - "AllocaInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const AllocaInst *alloca_inst = cast(inst); if (alloca_inst->isArrayAllocation()) { LLDB_LOGF(log, @@ -871,16 +863,7 @@ } break; case Instruction::BitCast: case Instruction::ZExt: { - const CastInst *cast_inst = dyn_cast(inst); - - if (!cast_inst) { - LLDB_LOGF( - log, "getOpcode() returns %s, but instruction is not a BitCastInst", - cast_inst->getOpcodeName()); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const CastInst *cast_inst = cast(inst); Value *source = cast_inst->getOperand(0); @@ -896,16 +879,7 @@ frame.AssignValue(inst, S, module); } break; case Instruction::SExt: { - const CastInst *cast_inst = dyn_cast(inst); - - if (!cast_inst) { - LLDB_LOGF( - log, "getOpcode() returns %s, but instruction is not a BitCastInst", - cast_inst->getOpcodeName()); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const CastInst *cast_inst = cast(inst); Value *source = cast_inst->getOperand(0); @@ -925,15 +899,7 @@ frame.AssignValue(inst, S_signextend, module); } break; case Instruction::Br: { - const BranchInst *br_inst = dyn_cast(inst); - - if (!br_inst) { - LLDB_LOGF( - log, "getOpcode() returns Br, but instruction is not a BranchInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const BranchInst *br_inst = cast(inst); if (br_inst->isConditional()) { Value *condition = br_inst->getCondition(); @@ -967,15 +933,7 @@ } continue; case Instruction::PHI: { - const PHINode *phi_inst = dyn_cast(inst); - - if (!phi_inst) { - LLDB_LOGF(log, - "getOpcode() returns PHI, but instruction is not a PHINode"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const PHINode *phi_inst = cast(inst); if (!frame.m_prev_bb) { LLDB_LOGF(log, "Encountered PHI node without having jumped from another " @@ -1002,15 +960,7 @@ } } break; case Instruction::GetElementPtr: { - const GetElementPtrInst *gep_inst = dyn_cast(inst); - - if (!gep_inst) { - LLDB_LOGF(log, "getOpcode() returns GetElementPtr, but instruction is " - "not a GetElementPtrInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const GetElementPtrInst *gep_inst = cast(inst); const Value *pointer_operand = gep_inst->getPointerOperand(); Type *src_elem_ty = gep_inst->getSourceElementType(); @@ -1072,16 +1022,7 @@ } } break; case Instruction::ICmp: { - const ICmpInst *icmp_inst = dyn_cast(inst); - - if (!icmp_inst) { - LLDB_LOGF( - log, - "getOpcode() returns ICmp, but instruction is not an ICmpInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const ICmpInst *icmp_inst = cast(inst); CmpInst::Predicate predicate = icmp_inst->getPredicate(); @@ -1168,16 +1109,7 @@ } } break; case Instruction::IntToPtr: { - const IntToPtrInst *int_to_ptr_inst = dyn_cast(inst); - - if (!int_to_ptr_inst) { - LLDB_LOGF(log, - "getOpcode() returns IntToPtr, but instruction is not an " - "IntToPtrInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const IntToPtrInst *int_to_ptr_inst = cast(inst); Value *src_operand = int_to_ptr_inst->getOperand(0); @@ -1199,16 +1131,7 @@ } } break; case Instruction::PtrToInt: { - const PtrToIntInst *ptr_to_int_inst = dyn_cast(inst); - - if (!ptr_to_int_inst) { - LLDB_LOGF(log, - "getOpcode() returns PtrToInt, but instruction is not an " - "PtrToIntInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const PtrToIntInst *ptr_to_int_inst = cast(inst); Value *src_operand = ptr_to_int_inst->getOperand(0); @@ -1230,16 +1153,7 @@ } } break; case Instruction::Trunc: { - const TruncInst *trunc_inst = dyn_cast(inst); - - if (!trunc_inst) { - LLDB_LOGF( - log, - "getOpcode() returns Trunc, but instruction is not a TruncInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const TruncInst *trunc_inst = cast(inst); Value *src_operand = trunc_inst->getOperand(0); @@ -1261,15 +1175,7 @@ } } break; case Instruction::Load: { - const LoadInst *load_inst = dyn_cast(inst); - - if (!load_inst) { - LLDB_LOGF( - log, "getOpcode() returns Load, but instruction is not a LoadInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const LoadInst *load_inst = cast(inst); // The semantics of Load are: // Create a region D that will contain the loaded data @@ -1351,16 +1257,7 @@ return true; } case Instruction::Store: { - const StoreInst *store_inst = dyn_cast(inst); - - if (!store_inst) { - LLDB_LOGF( - log, - "getOpcode() returns Store, but instruction is not a StoreInst"); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const StoreInst *store_inst = cast(inst); // The semantics of Store are: // Resolve the region D containing the data to be stored @@ -1436,16 +1333,7 @@ } } break; case Instruction::Call: { - const CallInst *call_inst = dyn_cast(inst); - - if (!call_inst) { - LLDB_LOGF(log, - "getOpcode() returns %s, but instruction is not a CallInst", - inst->getOpcodeName()); - error.SetErrorToGenericError(); - error.SetErrorString(interpreter_internal_error); - return false; - } + const CallInst *call_inst = cast(inst); if (CanIgnoreCall(call_inst)) break;