C++11: Use foreach in ScopDetection

llvm-svn: 202634
This commit is contained in:
Tobias Grosser 2014-03-02 12:02:46 +00:00
parent e67972c462
commit 00dc309a08
1 changed files with 17 additions and 25 deletions

View File

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