diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp index 58e4ad971e8..3385f0695fe 100644 --- a/lib/CodeGen/StackProtector.cpp +++ b/lib/CodeGen/StackProtector.cpp @@ -212,20 +212,16 @@ bool StackProtector::RequiresStackProtector() { Attribute::StackProtect)) return false; - for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) { - BasicBlock *BB = I; - - for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; - ++II) { - if (AllocaInst *AI = dyn_cast(II)) { + for (const BasicBlock &BB : *F) { + for (const Instruction &I : BB) { + if (const AllocaInst *AI = dyn_cast(&I)) { if (AI->isArrayAllocation()) { // SSP-Strong: Enable protectors for any call to alloca, regardless // of size. if (Strong) return true; - if (const ConstantInt *CI = - dyn_cast(AI->getArraySize())) { + if (const auto *CI = dyn_cast(AI->getArraySize())) { if (CI->getLimitedValue(SSPBufferSize) >= SSPBufferSize) { // A call to alloca with size >= SSPBufferSize requires // stack protectors.