Skip to content

Commit af4adb0

Browse files
committed
[lldb][NFC] Use range-based for loops in IRInterpreter
1 parent b6ffa2f commit af4adb0

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

lldb/source/Expression/IRInterpreter.cpp

+12-16
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,8 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
490490
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
491491

492492
bool saw_function_with_body = false;
493-
494-
for (Module::iterator fi = module.begin(), fe = module.end(); fi != fe;
495-
++fi) {
496-
if (fi->begin() != fi->end()) {
493+
for (Function &f : module) {
494+
if (f.begin() != f.end()) {
497495
if (saw_function_with_body) {
498496
LLDB_LOGF(log, "More than one function in the module has a body");
499497
error.SetErrorToGenericError();
@@ -504,13 +502,11 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
504502
}
505503
}
506504

507-
for (Function::iterator bbi = function.begin(), bbe = function.end();
508-
bbi != bbe; ++bbi) {
509-
for (BasicBlock::iterator ii = bbi->begin(), ie = bbi->end(); ii != ie;
510-
++ii) {
511-
switch (ii->getOpcode()) {
505+
for (BasicBlock &bb : function) {
506+
for (Instruction &ii : bb) {
507+
switch (ii.getOpcode()) {
512508
default: {
513-
LLDB_LOGF(log, "Unsupported instruction: %s", PrintValue(&*ii).c_str());
509+
LLDB_LOGF(log, "Unsupported instruction: %s", PrintValue(&ii).c_str());
514510
error.SetErrorToGenericError();
515511
error.SetErrorString(unsupported_opcode_error);
516512
return false;
@@ -522,7 +518,7 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
522518
case Instruction::PHI:
523519
break;
524520
case Instruction::Call: {
525-
CallInst *call_inst = dyn_cast<CallInst>(ii);
521+
CallInst *call_inst = dyn_cast<CallInst>(&ii);
526522

527523
if (!call_inst) {
528524
error.SetErrorToGenericError();
@@ -532,7 +528,7 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
532528

533529
if (!CanIgnoreCall(call_inst) && !support_function_calls) {
534530
LLDB_LOGF(log, "Unsupported instruction: %s",
535-
PrintValue(&*ii).c_str());
531+
PrintValue(&ii).c_str());
536532
error.SetErrorToGenericError();
537533
error.SetErrorString(unsupported_opcode_error);
538534
return false;
@@ -541,7 +537,7 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
541537
case Instruction::GetElementPtr:
542538
break;
543539
case Instruction::ICmp: {
544-
ICmpInst *icmp_inst = dyn_cast<ICmpInst>(ii);
540+
ICmpInst *icmp_inst = dyn_cast<ICmpInst>(&ii);
545541

546542
if (!icmp_inst) {
547543
error.SetErrorToGenericError();
@@ -552,7 +548,7 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
552548
switch (icmp_inst->getPredicate()) {
553549
default: {
554550
LLDB_LOGF(log, "Unsupported ICmp predicate: %s",
555-
PrintValue(&*ii).c_str());
551+
PrintValue(&ii).c_str());
556552

557553
error.SetErrorToGenericError();
558554
error.SetErrorString(unsupported_opcode_error);
@@ -594,8 +590,8 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
594590
break;
595591
}
596592

597-
for (int oi = 0, oe = ii->getNumOperands(); oi != oe; ++oi) {
598-
Value *operand = ii->getOperand(oi);
593+
for (unsigned oi = 0, oe = ii.getNumOperands(); oi != oe; ++oi) {
594+
Value *operand = ii.getOperand(oi);
599595
Type *operand_type = operand->getType();
600596

601597
switch (operand_type->getTypeID()) {

0 commit comments

Comments
 (0)