C++11: Use foreach in ScopDetection
llvm-svn: 202634
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 5c25507..bb697d7 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -332,8 +332,8 @@
std::vector<Value *> Pointers;
- for (AliasSet::iterator AI = AS.begin(), AE = AS.end(); AI != AE; ++AI)
- Pointers.push_back(AI.getPointer());
+ for (auto I: AS)
+ Pointers.push_back(I.getValue());
std::sort(Pointers.begin(), Pointers.end());
@@ -607,12 +607,12 @@
static unsigned eraseAllChildren(std::set<const Region *> &Regs,
const Region *R) {
unsigned Count = 0;
- for (Region::const_iterator I = R->begin(), E = R->end(); I != E; ++I) {
- if (Regs.find(*I) != Regs.end()) {
+ for (auto SubRegion: *R) {
+ if (Regs.find(SubRegion) != Regs.end()) {
++Count;
- Regs.erase(*I);
+ Regs.erase(SubRegion);
} else {
- Count += eraseAllChildren(Regs, *I);
+ Count += eraseAllChildren(Regs, SubRegion);
}
}
return Count;
@@ -633,8 +633,8 @@
InvalidRegions[&R] = LastFailure;
- for (Region::iterator I = R.begin(), E = R.end(); I != E; ++I)
- findScops(**I);
+ for (auto SubRegion: R)
+ findScops(*SubRegion);
// Try to expand regions.
//
@@ -644,14 +644,10 @@
std::vector<Region *> ToExpand;
- for (Region::iterator I = R.begin(), E = R.end(); I != E; ++I)
- ToExpand.push_back(*I);
+ for (auto SubRegion: R)
+ ToExpand.push_back(SubRegion);
- for (std::vector<Region *>::iterator RI = ToExpand.begin(),
- RE = ToExpand.end();
- RI != RE; ++RI) {
- Region *CurrentRegion = *RI;
-
+ for (auto CurrentRegion: ToExpand) {
// Skip invalid regions. Regions may become invalid, if they are element of
// an already expanded region.
if (ValidRegions.find(CurrentRegion) == ValidRegions.end())
@@ -804,11 +800,11 @@
}
void ScopDetection::printLocations(llvm::Function &F) {
- for (iterator RI = begin(), RE = end(); RI != RE; ++RI) {
+ for (auto R: *this) {
unsigned LineEntry, LineExit;
std::string FileName;
- getDebugLocation(*RI, LineEntry, LineExit, FileName);
+ getDebugLocation(R, LineEntry, LineExit, FileName);
DiagnosticScopFound Diagnostic(F, FileName, LineEntry, LineExit);
F.getContext().diagnose(Diagnostic);
}
@@ -850,10 +846,8 @@
if (!VerifyScops)
return;
- for (RegionSet::const_iterator I = ValidRegions.begin(),
- E = ValidRegions.end();
- I != E; ++I)
- verifyRegion(**I);
+ for (auto R: ValidRegions)
+ verifyRegion(*R);
}
void ScopDetection::getAnalysisUsage(AnalysisUsage &AU) const {
@@ -868,10 +862,8 @@
}
void ScopDetection::print(raw_ostream &OS, const Module *) const {
- for (RegionSet::const_iterator I = ValidRegions.begin(),
- E = ValidRegions.end();
- I != E; ++I)
- OS << "Valid Region for Scop: " << (*I)->getNameStr() << '\n';
+ for (auto R: ValidRegions)
+ OS << "Valid Region for Scop: " << R->getNameStr() << '\n';
OS << "\n";
}