From 281f5687205d2a1e94d2dd9c8585a1afb669327e Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 20 Dec 2014 21:37:51 +0000 Subject: [PATCH] CodeGen: constify and use range loop for SSP Use range-based for loop and constify the iterators. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224683 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/StackProtector.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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. -- 2.34.1