summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2016-06-26 12:28:59 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2016-06-26 12:28:59 +0000
commit135f735af149e305635ba3886065b493d5c2bf8c (patch)
treeefc8ab49d69279615e3d0a3563a7d05354270bf5 /llvm/lib/Transforms/Instrumentation
parentff976c99c79d7a00f1c836a57c3e7499316553c4 (diff)
downloadbcm5719-llvm-135f735af149e305635ba3886065b493d5c2bf8c.tar.gz
bcm5719-llvm-135f735af149e305635ba3886065b493d5c2bf8c.zip
Apply clang-tidy's modernize-loop-convert to most of lib/Transforms.
Only minor manual fixes. No functionality change intended. llvm-svn: 273808
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation')
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp6
-rw-r--r--llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp5
-rw-r--r--llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp26
-rw-r--r--llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp25
4 files changed, 25 insertions, 37 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 33693eb5417..736adeccb58 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1010,9 +1010,9 @@ void AddressSanitizer::instrumentPointerComparisonOrSubtraction(
IRBuilder<> IRB(I);
Function *F = isa<ICmpInst>(I) ? AsanPtrCmpFunction : AsanPtrSubFunction;
Value *Param[2] = {I->getOperand(0), I->getOperand(1)};
- for (int i = 0; i < 2; i++) {
- if (Param[i]->getType()->isPointerTy())
- Param[i] = IRB.CreatePointerCast(Param[i], IntptrTy);
+ for (Value *&i : Param) {
+ if (i->getType()->isPointerTy())
+ i = IRB.CreatePointerCast(i, IntptrTy);
}
IRB.CreateCall(F, Param);
}
diff --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
index f2ccc6d3272..d4c8369fa9d 100644
--- a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -185,9 +185,8 @@ bool BoundsChecking::runOnFunction(Function &F) {
}
bool MadeChange = false;
- for (std::vector<Instruction*>::iterator i = WorkList.begin(),
- e = WorkList.end(); i != e; ++i) {
- Inst = *i;
+ for (Instruction *i : WorkList) {
+ Inst = i;
Builder->SetInsertPoint(Inst);
if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index c964a1f37e5..b34d5b8c45a 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -791,25 +791,20 @@ bool DataFlowSanitizer::runOnModule(Module &M) {
}
}
- for (std::vector<Function *>::iterator i = FnsToInstrument.begin(),
- e = FnsToInstrument.end();
- i != e; ++i) {
- if (!*i || (*i)->isDeclaration())
+ for (Function *i : FnsToInstrument) {
+ if (!i || i->isDeclaration())
continue;
- removeUnreachableBlocks(**i);
+ removeUnreachableBlocks(*i);
- DFSanFunction DFSF(*this, *i, FnsWithNativeABI.count(*i));
+ DFSanFunction DFSF(*this, i, FnsWithNativeABI.count(i));
// DFSanVisitor may create new basic blocks, which confuses df_iterator.
// Build a copy of the list before iterating over it.
- llvm::SmallVector<BasicBlock *, 4> BBList(
- depth_first(&(*i)->getEntryBlock()));
+ llvm::SmallVector<BasicBlock *, 4> BBList(depth_first(&i->getEntryBlock()));
- for (llvm::SmallVector<BasicBlock *, 4>::iterator i = BBList.begin(),
- e = BBList.end();
- i != e; ++i) {
- Instruction *Inst = &(*i)->front();
+ for (BasicBlock *i : BBList) {
+ Instruction *Inst = &i->front();
while (1) {
// DFSanVisitor may split the current basic block, changing the current
// instruction's next pointer and moving the next instruction to the
@@ -1066,11 +1061,10 @@ Value *DFSanFunction::loadShadow(Value *Addr, uint64_t Size, uint64_t Align,
SmallVector<Value *, 2> Objs;
GetUnderlyingObjects(Addr, Objs, Pos->getModule()->getDataLayout());
bool AllConstants = true;
- for (SmallVector<Value *, 2>::iterator i = Objs.begin(), e = Objs.end();
- i != e; ++i) {
- if (isa<Function>(*i) || isa<BlockAddress>(*i))
+ for (Value *Obj : Objs) {
+ if (isa<Function>(Obj) || isa<BlockAddress>(Obj))
continue;
- if (isa<GlobalVariable>(*i) && cast<GlobalVariable>(*i)->isConstant())
+ if (isa<GlobalVariable>(Obj) && cast<GlobalVariable>(Obj)->isConstant())
continue;
AllConstants = false;
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index df48897f2c7..1288175200c 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -265,10 +265,9 @@ namespace {
void writeOut() {
uint32_t Len = 3;
SmallVector<StringMapEntry<GCOVLines *> *, 32> SortedLinesByFile;
- for (StringMap<GCOVLines *>::iterator I = LinesByFile.begin(),
- E = LinesByFile.end(); I != E; ++I) {
- Len += I->second->length();
- SortedLinesByFile.push_back(&*I);
+ for (auto &I : LinesByFile) {
+ Len += I.second->length();
+ SortedLinesByFile.push_back(&I);
}
writeBytes(LinesTag, 4);
@@ -280,10 +279,8 @@ namespace {
StringMapEntry<GCOVLines *> *RHS) {
return LHS->getKey() < RHS->getKey();
});
- for (SmallVectorImpl<StringMapEntry<GCOVLines *> *>::iterator
- I = SortedLinesByFile.begin(), E = SortedLinesByFile.end();
- I != E; ++I)
- (*I)->getValue()->writeOut();
+ for (auto &I : SortedLinesByFile)
+ I->getValue()->writeOut();
write(0);
write(0);
}
@@ -742,8 +739,8 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable(
EdgeTable[i] = NullValue;
unsigned Edge = 0;
- for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
- TerminatorInst *TI = BB->getTerminator();
+ for (BasicBlock &BB : *F) {
+ TerminatorInst *TI = BB.getTerminator();
int Successors = isa<ReturnInst>(TI) ? 1 : TI->getNumSuccessors();
if (Successors > 1 && !isa<BranchInst>(TI) && !isa<ReturnInst>(TI)) {
for (int i = 0; i != Successors; ++i) {
@@ -752,7 +749,7 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable(
Value *Counter = Builder.CreateConstInBoundsGEP2_64(Counters, 0,
Edge + i);
EdgeTable[((Succs.idFor(Succ) - 1) * Preds.size()) +
- (Preds.idFor(&*BB) - 1)] = cast<Constant>(Counter);
+ (Preds.idFor(&BB) - 1)] = cast<Constant>(Counter);
}
}
Edge += Successors;
@@ -972,10 +969,8 @@ insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> > CountersBySP) {
Builder.CreateCall(WriteoutF, {});
// Zero out the counters.
- for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
- I = CountersBySP.begin(), E = CountersBySP.end();
- I != E; ++I) {
- GlobalVariable *GV = I->first;
+ for (const auto &I : CountersBySP) {
+ GlobalVariable *GV = I.first;
Constant *Null = Constant::getNullValue(GV->getValueType());
Builder.CreateStore(Null, GV);
}
OpenPOWER on IntegriCloud