ScopDetect: Make foreachs 'const auto &'

We mostly iterate over read-only values. Following a suggestion by Duncan P.N
Exons Smith, we use the construct 'const auto &' for this.

llvm-svn: 202651
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 454bb99..a5cfc2c 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -332,7 +332,7 @@
 
   std::vector<Value *> Pointers;
 
-  for (auto I : AS)
+  for (const auto &I : AS)
     Pointers.push_back(I.getValue());
 
   std::sort(Pointers.begin(), Pointers.end());
@@ -607,7 +607,7 @@
 static unsigned eraseAllChildren(std::set<const Region *> &Regs,
                                  const Region *R) {
   unsigned Count = 0;
-  for (auto SubRegion : *R) {
+  for (const auto &SubRegion : *R) {
     if (Regs.find(SubRegion) != Regs.end()) {
       ++Count;
       Regs.erase(SubRegion);
@@ -633,7 +633,7 @@
 
   InvalidRegions[&R] = LastFailure;
 
-  for (auto SubRegion : R)
+  for (const auto &SubRegion : R)
     findScops(*SubRegion);
 
   // Try to expand regions.
@@ -644,10 +644,10 @@
 
   std::vector<Region *> ToExpand;
 
-  for (auto SubRegion : R)
+  for (const auto &SubRegion : R)
     ToExpand.push_back(SubRegion);
 
-  for (auto CurrentRegion : ToExpand) {
+  for (const 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())
@@ -800,7 +800,7 @@
 }
 
 void ScopDetection::printLocations(llvm::Function &F) {
-  for (auto R : *this) {
+  for (const auto &R : *this) {
     unsigned LineEntry, LineExit;
     std::string FileName;
 
@@ -846,7 +846,7 @@
   if (!VerifyScops)
     return;
 
-  for (auto R : ValidRegions)
+  for (const auto &R : ValidRegions)
     verifyRegion(*R);
 }
 
@@ -862,7 +862,7 @@
 }
 
 void ScopDetection::print(raw_ostream &OS, const Module *) const {
-  for (auto R : ValidRegions)
+  for (const auto &R : ValidRegions)
     OS << "Valid Region for Scop: " << R->getNameStr() << '\n';
 
   OS << "\n";