[clang-tools-extra] r252308 - Use the old index identifier by default, instead of 'elem'.

Angel Garcia Gomez via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 6 07:03:15 PST 2015


Author: angelgarcia
Date: Fri Nov  6 09:03:14 2015
New Revision: 252308

URL: http://llvm.org/viewvc/llvm-project?rev=252308&view=rev
Log:
Use the old index identifier by default, instead of 'elem'.

Summary: Use the old index name in the cases where the check would come up with an invented name.

Reviewers: klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D14438

Modified:
    clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=252308&r1=252307&r2=252308&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Fri Nov  6 09:03:14 2015
@@ -831,54 +831,7 @@ std::string VariableNamer::createIndexNa
       return IteratorName;
   }
 
-  std::string Elem;
-  switch (Style) {
-  case NS_CamelBack:
-  case NS_LowerCase:
-    Elem = "elem";
-    break;
-  case NS_CamelCase:
-    Elem = "Elem";
-    break;
-  case NS_UpperCase:
-    Elem = "ELEM";
-  }
-  // E.g.: (auto elem : container)
-  if (!declarationExists(Elem))
-    return Elem;
-
-  IteratorName = AppendWithStyle(ContainerName, OldIndex->getName());
-  // E.g.: (auto container_i : container)
-  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
-    return IteratorName;
-
-  IteratorName = AppendWithStyle(ContainerName, Elem);
-  // E.g.: (auto container_elem : container)
-  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
-    return IteratorName;
-
-  // Someone defeated my naming scheme...
-  std::string GiveMeName;
-  switch (Style) {
-  case NS_CamelBack:
-    GiveMeName = "giveMeName";
-    break;
-  case NS_CamelCase:
-    GiveMeName = "GiveMeName";
-    break;
-  case NS_LowerCase:
-    GiveMeName = "give_me_name_";
-    break;
-  case NS_UpperCase:
-    GiveMeName = "GIVE_ME_NAME_";
-  }
-  int Attempt = 0;
-  do {
-    IteratorName = GiveMeName + std::to_string(Attempt++);
-  } while (declarationExists(IteratorName) ||
-           IteratorName == OldIndex->getName());
-
-  return IteratorName;
+  return OldIndex->getName();
 }
 
 /// \brief Determines whether or not the the name \a Symbol conflicts with

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=252308&r1=252307&r2=252308&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp Fri Nov  6 09:03:14 2015
@@ -18,8 +18,8 @@ void f() {
     int K;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: Sum += Elem;
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: Sum += I;
   // CHECK-FIXES-NEXT: int K;
 
   for (int I = 0; I < N; ++I) {
@@ -27,66 +27,66 @@ void f() {
     Sum += Arr[I] + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 
   for (int I = 0; I < N; ++I) {
     int X = Arr[I];
     int Y = Arr[I] + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: int X = Elem;
-  // CHECK-FIXES-NEXT: int Y = Elem + 2;
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: int X = I;
+  // CHECK-FIXES-NEXT: int Y = I + 2;
 
   for (int I = 0; I < N; ++I) {
     int X = N;
     X = Arr[I];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
+  // CHECK-FIXES: for (int I : Arr)
   // CHECK-FIXES-NEXT: int X = N;
-  // CHECK-FIXES-NEXT: X = Elem;
+  // CHECK-FIXES-NEXT: X = I;
 
   for (int I = 0; I < N; ++I) {
     Arr[I] += 1;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Arr)
-  // CHECK-FIXES-NEXT: Elem += 1;
+  // CHECK-FIXES: for (int & I : Arr)
+  // CHECK-FIXES-NEXT: I += 1;
 
   for (int I = 0; I < N; ++I) {
     int X = Arr[I] + 2;
     Arr[I]++;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Arr)
-  // CHECK-FIXES-NEXT: int X = Elem + 2;
-  // CHECK-FIXES-NEXT: Elem++;
+  // CHECK-FIXES: for (int & I : Arr)
+  // CHECK-FIXES-NEXT: int X = I + 2;
+  // CHECK-FIXES-NEXT: I++;
 
   for (int I = 0; I < N; ++I) {
     Arr[I] = 4 + Arr[I];
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Arr)
-  // CHECK-FIXES-NEXT: Elem = 4 + Elem;
+  // CHECK-FIXES: for (int & I : Arr)
+  // CHECK-FIXES-NEXT: I = 4 + I;
 
   for (int I = 0; I < NMinusOne + 1; ++I) {
     Sum += Arr[I];
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: Sum += Elem;
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: Sum += I;
 
   for (int I = 0; I < N; ++I) {
     printf("Fibonacci number %d has address %p\n", Arr[I], &Arr[I]);
     Sum += Arr[I] + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Arr)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number %d has address %p\n", Elem, &Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int & I : Arr)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number %d has address %p\n", I, &I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 
   Val Teas[N];
   for (int I = 0; I < N; ++I) {
@@ -102,24 +102,24 @@ const int *constArray() {
     printf("2 * %d = %d\n", ConstArr[I], ConstArr[I] + ConstArr[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : ConstArr)
-  // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem, Elem + Elem);
+  // CHECK-FIXES: for (int I : ConstArr)
+  // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", I, I + I);
 
   const NonTriviallyCopyable NonCopy[N]{};
   for (int I = 0; I < N; ++I) {
     printf("2 * %d = %d\n", NonCopy[I].X, NonCopy[I].X + NonCopy[I].X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (const auto & Elem : NonCopy)
-  // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem.X, Elem.X + Elem.X);
+  // CHECK-FIXES: for (const auto & I : NonCopy)
+  // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", I.X, I.X + I.X);
 
   const TriviallyCopyableButBig Big[N]{};
   for (int I = 0; I < N; ++I) {
     printf("2 * %d = %d\n", Big[I].X, Big[I].X + Big[I].X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (const auto & Elem : Big)
-  // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem.X, Elem.X + Elem.X);
+  // CHECK-FIXES: for (const auto & I : Big)
+  // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", I.X, I.X + I.X);
 
   bool Something = false;
   for (int I = 0; I < N; ++I) {
@@ -127,9 +127,9 @@ const int *constArray() {
       return &ConstArr[I];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (const int & Elem : ConstArr)
+  // CHECK-FIXES: for (const int & I : ConstArr)
   // CHECK-FIXES-NEXT: if (Something)
-  // CHECK-FIXES-NEXT: return &Elem;
+  // CHECK-FIXES-NEXT: return &I;
 }
 
 struct HasArr {
@@ -140,15 +140,15 @@ struct HasArr {
       printf("%d", Arr[I]);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (int Elem : Arr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem);
+    // CHECK-FIXES: for (int I : Arr)
+    // CHECK-FIXES-NEXT: printf("%d", I);
 
     for (int I = 0; I < N; ++I) {
       printf("%d", ValArr[I].X);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : ValArr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem.X);
+    // CHECK-FIXES: for (auto & I : ValArr)
+    // CHECK-FIXES-NEXT: printf("%d", I.X);
   }
 
   void explicitThis() {
@@ -156,15 +156,15 @@ struct HasArr {
       printf("%d", this->Arr[I]);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (int Elem : this->Arr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem);
+    // CHECK-FIXES: for (int I : this->Arr)
+    // CHECK-FIXES-NEXT: printf("%d", I);
 
     for (int I = 0; I < N; ++I) {
       printf("%d", this->ValArr[I].X);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : this->ValArr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem.X);
+    // CHECK-FIXES: for (auto & I : this->ValArr)
+    // CHECK-FIXES-NEXT: printf("%d", I.X);
   }
 };
 
@@ -175,15 +175,15 @@ struct HasIndirectArr {
       printf("%d", HA.Arr[I]);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (int Elem : HA.Arr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem);
+    // CHECK-FIXES: for (int I : HA.Arr)
+    // CHECK-FIXES-NEXT: printf("%d", I);
 
     for (int I = 0; I < N; ++I) {
       printf("%d", HA.ValArr[I].X);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : HA.ValArr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem.X);
+    // CHECK-FIXES: for (auto & I : HA.ValArr)
+    // CHECK-FIXES-NEXT: printf("%d", I.X);
   }
 
   void explicitThis() {
@@ -191,15 +191,15 @@ struct HasIndirectArr {
       printf("%d", this->HA.Arr[I]);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (int Elem : this->HA.Arr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem);
+    // CHECK-FIXES: for (int I : this->HA.Arr)
+    // CHECK-FIXES-NEXT: printf("%d", I);
 
     for (int I = 0; I < N; ++I) {
       printf("%d", this->HA.ValArr[I].X);
     }
     // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : this->HA.ValArr)
-    // CHECK-FIXES-NEXT: printf("%d", Elem.X);
+    // CHECK-FIXES: for (auto & I : this->HA.ValArr)
+    // CHECK-FIXES-NEXT: printf("%d", I.X);
   }
 };
 
@@ -217,8 +217,8 @@ void memberFunctionPointer() {
   for (int I = 0; I < N; ++I)
     (V.*mfpArr[I])();
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : mfpArr)
-  // CHECK-FIXES-NEXT: (V.*Elem)();
+  // CHECK-FIXES: for (auto & I : mfpArr)
+  // CHECK-FIXES-NEXT: (V.*I)();
 
   struct Foo {
     int (Val::*f)();
@@ -227,8 +227,8 @@ void memberFunctionPointer() {
   for (int I = 0; I < N; ++I)
     int R = (V.*(Foo[I].f))();
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Foo)
-  // CHECK-FIXES-NEXT: int R = (V.*(Elem.f))();
+  // CHECK-FIXES: for (auto & I : Foo)
+  // CHECK-FIXES-NEXT: int R = (V.*(I.f))();
 
 }
 
@@ -243,24 +243,24 @@ void f() {
     printf("I found %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Tt)
-  // CHECK-FIXES-NEXT: printf("I found %d\n", Elem);
+  // CHECK-FIXES: for (int & It : Tt)
+  // CHECK-FIXES-NEXT: printf("I found %d\n", It);
 
   T *Pt;
   for (T::iterator It = Pt->begin(), E = Pt->end(); It != E; ++It) {
     printf("I found %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : *Pt)
-  // CHECK-FIXES-NEXT: printf("I found %d\n", Elem);
+  // CHECK-FIXES: for (int & It : *Pt)
+  // CHECK-FIXES-NEXT: printf("I found %d\n", It);
 
   S Ss;
   for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
     printf("s has value %d\n", (*It).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   S *Ps;
   for (S::iterator It = Ps->begin(), E = Ps->end(); It != E; ++It) {
@@ -274,58 +274,58 @@ void f() {
     printf("s has value %d\n", (*It).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto Elem : Ss)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto It : Ss)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
     printf("s has value %d\n", It->X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
     It->X = 3;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: Elem.X = 3;
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: It.X = 3;
 
   for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
     (*It).X = 3;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: Elem.X = 3;
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: It.X = 3;
 
   for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
     It->nonConstFun(4, 5);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: Elem.nonConstFun(4, 5);
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: It.nonConstFun(4, 5);
 
   U Uu;
   for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
     printf("s has value %d\n", It->X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Uu)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Uu)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
     printf("s has value %d\n", (*It).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Uu)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Uu)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   U::iterator A;
   for (U::iterator I = Uu.begin(), E = Uu.end(); I != E; ++I)
     int K = A->X + I->X;
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Uu)
-  // CHECK-FIXES-NEXT: int K = A->X + Elem.X;
+  // CHECK-FIXES: for (auto & I : Uu)
+  // CHECK-FIXES-NEXT: int K = A->X + I.X;
 
   dependent<int> V;
   for (dependent<int>::iterator It = V.begin(), E = V.end();
@@ -333,16 +333,16 @@ void f() {
     printf("Fibonacci number is %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
+  // CHECK-FIXES: for (int & It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   for (dependent<int>::iterator It(V.begin()), E = V.end();
        It != E; ++It) {
     printf("Fibonacci number is %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
+  // CHECK-FIXES: for (int & It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   doublyDependent<int, int> Intmap;
   for (doublyDependent<int, int>::iterator It = Intmap.begin(), E = Intmap.end();
@@ -350,8 +350,8 @@ void f() {
     printf("Intmap[%d] = %d", It->first, It->second);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Intmap)
-  // CHECK-FIXES: printf("Intmap[%d] = %d", Elem.first, Elem.second);
+  // CHECK-FIXES: for (auto & It : Intmap)
+  // CHECK-FIXES: printf("Intmap[%d] = %d", It.first, It.second);
 
   // PtrSet's iterator dereferences by value so auto & can't be used.
   {
@@ -395,15 +395,15 @@ void f() {
     printf("%d\n", (**I).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Dpp)
-  // CHECK-FIXES-NEXT: printf("%d\n", (*Elem).X);
+  // CHECK-FIXES: for (auto & I : Dpp)
+  // CHECK-FIXES-NEXT: printf("%d\n", (*I).X);
 
   for (dependent<Val *>::iterator I = Dpp.begin(), E = Dpp.end(); I != E; ++I) {
     printf("%d\n", (*I)->X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Dpp)
-  // CHECK-FIXES-NEXT: printf("%d\n", Elem->X);
+  // CHECK-FIXES: for (auto & I : Dpp)
+  // CHECK-FIXES-NEXT: printf("%d\n", I->X);
 }
 
 // Tests to verify the proper use of auto where the init variable type and the
@@ -416,8 +416,8 @@ void different_type() {
     printf("s has value %d\n", (*It).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto Elem : Ss)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto It : Ss)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   S *Ps;
   for (S::const_iterator It = Ps->begin(), E = Ps->end(); It != E; ++It) {
@@ -462,12 +462,12 @@ public:
     for (iterator I = begin(), E = end(); I != E; ++I)
       (void) *I;
     // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : *this)
+    // CHECK-FIXES: for (auto & I : *this)
 
     for (iterator I = C::begin(), E = C::end(); I != E; ++I)
       (void) *I;
     // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : *this)
+    // CHECK-FIXES: for (auto & I : *this)
 
     for (iterator I = begin(), E = end(); I != E; ++I) {
       (void) *I;
@@ -477,7 +477,7 @@ public:
     for (iterator I = begin(); I != end(); ++I)
       (void) *I;
     // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : *this)
+    // CHECK-FIXES: for (auto & I : *this)
 
     for (iterator I = begin(); I != end(); ++I) {
       (void) *I;
@@ -489,12 +489,12 @@ public:
     for (const_iterator I = begin(), E = end(); I != E; ++I)
       (void) *I;
     // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto Elem : *this)
+    // CHECK-FIXES: for (auto I : *this)
 
     for (const_iterator I = C::begin(), E = C::end(); I != E; ++I)
       (void) *I;
     // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto Elem : *this)
+    // CHECK-FIXES: for (auto I : *this)
 
     for (const_iterator I = begin(), E = end(); I != E; ++I) {
       (void) *I;
@@ -516,7 +516,7 @@ public:
     for (iterator I = begin(), E = end(); I != E; ++I)
       (void) *I;
     // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-    // CHECK-FIXES: for (auto & Elem : *this)
+    // CHECK-FIXES: for (auto & I : *this)
   }
 };
 
@@ -539,27 +539,27 @@ void f() {
     Sum += V[I] + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int I : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 
   for (int I = 0, E = V.size(); I < E; ++I) {
     printf("Fibonacci number is %d\n", V.at(I));
     Sum += V.at(I) + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int I : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 
   for (int I = 0, E = Pv->size(); I < E; ++I) {
     printf("Fibonacci number is %d\n", Pv->at(I));
     Sum += Pv->at(I) + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : *Pv)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int I : *Pv)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 
   // This test will fail if size() isn't called repeatedly, since it
   // returns unsigned int, and 0 is deduced to be signed int.
@@ -570,18 +570,18 @@ void f() {
     Sum += (*Pv)[I] + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : *Pv)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int I : *Pv)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 
   for (int I = 0; I < Cv->size(); ++I) {
     printf("Fibonacci number is %d\n", Cv->at(I));
     Sum += Cv->at(I) + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : *Cv)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int I : *Cv)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 }
 
 // Ensure that 'const auto &' is used with containers of non-trivial types.
@@ -592,27 +592,27 @@ void constness() {
     Sum += Constv[I].X + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (const auto & Elem : Constv)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
-  // CHECK-FIXES-NEXT: Sum += Elem.X + 2;
+  // CHECK-FIXES: for (const auto & I : Constv)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
+  // CHECK-FIXES-NEXT: Sum += I.X + 2;
 
   for (int I = 0, E = Constv.size(); I < E; ++I) {
     printf("Fibonacci number is %d\n", Constv.at(I).X);
     Sum += Constv.at(I).X + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (const auto & Elem : Constv)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
-  // CHECK-FIXES-NEXT: Sum += Elem.X + 2;
+  // CHECK-FIXES: for (const auto & I : Constv)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
+  // CHECK-FIXES-NEXT: Sum += I.X + 2;
 
   for (int I = 0, E = Pconstv->size(); I < E; ++I) {
     printf("Fibonacci number is %d\n", Pconstv->at(I).X);
     Sum += Pconstv->at(I).X + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (const auto & Elem : *Pconstv)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
-  // CHECK-FIXES-NEXT: Sum += Elem.X + 2;
+  // CHECK-FIXES: for (const auto & I : *Pconstv)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
+  // CHECK-FIXES-NEXT: Sum += I.X + 2;
 
   // This test will fail if size() isn't called repeatedly, since it
   // returns unsigned int, and 0 is deduced to be signed int.
@@ -623,28 +623,28 @@ void constness() {
     Sum += (*Pconstv)[I].X + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (const auto & Elem : *Pconstv)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem.X);
-  // CHECK-FIXES-NEXT: Sum += Elem.X + 2;
+  // CHECK-FIXES: for (const auto & I : *Pconstv)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
+  // CHECK-FIXES-NEXT: Sum += I.X + 2;
 }
 
 void constRef(const dependent<int>& ConstVRef) {
   int sum = 0;
   // FIXME: This does not work with size_t (probably due to the implementation
   // of dependent); make dependent work exactly like a std container type.
-  for (int i = 0; i < ConstVRef.size(); ++i) {
-    sum += ConstVRef[i];
+  for (int I = 0; I < ConstVRef.size(); ++I) {
+    sum += ConstVRef[I];
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : ConstVRef)
-  // CHECK-FIXES-NEXT: sum += Elem;
+  // CHECK-FIXES: for (int I : ConstVRef)
+  // CHECK-FIXES-NEXT: sum += I;
 
   for (auto I = ConstVRef.begin(), E = ConstVRef.end(); I != E; ++I) {
     sum += *I;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : ConstVRef)
-  // CHECK-FIXES-NEXT: sum += Elem;
+  // CHECK-FIXES: for (int I : ConstVRef)
+  // CHECK-FIXES-NEXT: sum += I;
 }
 
 // Check for loops that don't mention containers.
@@ -695,15 +695,15 @@ void NoBeginEndTest() {
   for (unsigned I = 0, E = CBE.size(); I < E; ++I)
     printf("%d\n", CBE[I]);
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (unsigned int Elem : CBE)
-  // CHECK-FIXES-NEXT: printf("%d\n", Elem);
+  // CHECK-FIXES: for (unsigned int I : CBE)
+  // CHECK-FIXES-NEXT: printf("%d\n", I);
 
   const ConstBeginEnd Const_CBE;
   for (unsigned I = 0, E = Const_CBE.size(); I < E; ++I)
     printf("%d\n", Const_CBE[I]);
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (unsigned int Elem : Const_CBE)
-  // CHECK-FIXES-NEXT: printf("%d\n", Elem);
+  // CHECK-FIXES: for (unsigned int I : Const_CBE)
+  // CHECK-FIXES-NEXT: printf("%d\n", I);
 }
 
 struct DerefByValue {
@@ -721,17 +721,17 @@ void derefByValueTest() {
     printf("%d\n", DBV[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (unsigned int Elem : DBV)
-  // CHECK-FIXES-NEXT: printf("%d\n", Elem);
+  // CHECK-FIXES: for (unsigned int I : DBV)
+  // CHECK-FIXES-NEXT: printf("%d\n", I);
 
   for (unsigned I = 0, E = DBV.size(); I < E; ++I) {
     auto f = [DBV, I]() {};
     printf("%d\n", DBV[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (unsigned int Elem : DBV)
-  // CHECK-FIXES-NEXT: auto f = [DBV, &Elem]() {};
-  // CHECK-FIXES-NEXT: printf("%d\n", Elem);
+  // CHECK-FIXES: for (unsigned int I : DBV)
+  // CHECK-FIXES-NEXT: auto f = [DBV, &I]() {};
+  // CHECK-FIXES-NEXT: printf("%d\n", I);
 }
 
 void fundamentalTypesTest() {

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp?rev=252308&r1=252307&r2=252308&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp Fri Nov  6 09:03:14 2015
@@ -13,8 +13,8 @@ void naming() {
     printf("%d\n", arr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int elem : arr)
-  // CHECK-FIXES-NEXT: printf("%d\n", elem);
+  // CHECK-FIXES: for (int i : arr)
+  // CHECK-FIXES-NEXT: printf("%d\n", i);
 
   for (int i = 0; i < n; ++i) {
     printf("%d\n", nums[i]);
@@ -28,50 +28,6 @@ void naming() {
     printf("%d\n", nums[i] + num);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int elem : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", elem + num);
-
-  int elem = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int numsI : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", numsI + num + elem);
-
-  int numsI = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem + numsI);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int numsElem : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", numsElem + num + elem + numsI);
-
-  int numsElem = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem + numsI + numsElem);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int giveMeName0 : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", giveMeName0 + num + elem + numsI + numsElem);
-
-  int giveMeName0 = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem + numsI + numsElem + giveMeName0);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int giveMeName1 : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", giveMeName1 + num + elem + numsI + numsElem + giveMeName0);
-
-  int numsJ = 0;
-  for (int i = 0; i < n; ++i) {
-    for (int j = 0; j < n; ++j) {
-      printf("%d\n", nums[i] + nums[j] + num + elem + numsI + numsJ + numsElem);
-    }
-  }
-  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int giveMeName0 : nums)
-  // CHECK-FIXES: for (int giveMeName1 : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", giveMeName0 + giveMeName1 + num + elem + numsI + numsJ + numsElem);
+  // CHECK-FIXES: for (int i : nums)
+  // CHECK-FIXES-NEXT: printf("%d\n", i + num);
 }

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp?rev=252308&r1=252307&r2=252308&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp Fri Nov  6 09:03:14 2015
@@ -43,45 +43,45 @@ void memberFunctionsAndOperators() {
     Array[I].constMember(0);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (auto Elem : Array)
-  // CHECK-FIXES-NEXT: Elem.constMember(0);
+  // CHECK-FIXES: for (auto I : Array)
+  // CHECK-FIXES-NEXT: I.constMember(0);
 
   for (int I = 0; I < N; ++I) {
     if (Array[I] < OtherStr)
       foo();
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto Elem : Array)
-  // CHECK-FIXES-NEXT: if (Elem < OtherStr)
+  // CHECK-FIXES: for (auto I : Array)
+  // CHECK-FIXES-NEXT: if (I < OtherStr)
   for (int I = 0; I < N; ++I) {
     if (Right[I] < OtherRight)
       foo();
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (const auto & Elem : Right)
-  // CHECK-FIXES-NEXT: if (Elem < OtherRight)
+  // CHECK-FIXES: for (const auto & I : Right)
+  // CHECK-FIXES-NEXT: if (I < OtherRight)
 
   // Calling non-const member functions is not.
   for (int I = 0; I < N; ++I) {
     Array[I].nonConstMember(0);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Array)
-  // CHECK-FIXES-NEXT: Elem.nonConstMember(0);
+  // CHECK-FIXES: for (auto & I : Array)
+  // CHECK-FIXES-NEXT: I.nonConstMember(0);
 
   for (int I = 0; I < N; ++I) {
     Array[I] = OtherStr;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Array)
-  // CHECK-FIXES-NEXT: Elem = OtherStr;
+  // CHECK-FIXES: for (auto & I : Array)
+  // CHECK-FIXES-NEXT: I = OtherStr;
 
   for (int I = 0; I < N; ++I) {
     Right[I] = OtherRight;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Right)
-  // CHECK-FIXES-NEXT: Elem = OtherRight;
+  // CHECK-FIXES: for (auto & I : Right)
+  // CHECK-FIXES-NEXT: I = OtherRight;
 }
 
 void usedAsParameterToFunctionOrOperator() {
@@ -90,59 +90,59 @@ void usedAsParameterToFunctionOrOperator
     copyArg(Array[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto Elem : Array)
-  // CHECK-FIXES-NEXT: copyArg(Elem);
+  // CHECK-FIXES: for (auto I : Array)
+  // CHECK-FIXES-NEXT: copyArg(I);
 
   for (int I = 0; I < N; ++I) {
     copyArg(Right[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Right)
-  // CHECK-FIXES-NEXT: copyArg(Elem);
+  // CHECK-FIXES: for (auto & I : Right)
+  // CHECK-FIXES-NEXT: copyArg(I);
 
   // Using as a const reference argument is allowed.
   for (int I = 0; I < N; ++I) {
     constRefArg(Array[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto Elem : Array)
-  // CHECK-FIXES-NEXT: constRefArg(Elem);
+  // CHECK-FIXES: for (auto I : Array)
+  // CHECK-FIXES-NEXT: constRefArg(I);
 
   for (int I = 0; I < N; ++I) {
     if (OtherStr < Array[I])
       foo();
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto Elem : Array)
-  // CHECK-FIXES-NEXT: if (OtherStr < Elem)
+  // CHECK-FIXES: for (auto I : Array)
+  // CHECK-FIXES-NEXT: if (OtherStr < I)
 
   for (int I = 0; I < N; ++I) {
     constRefArg(Right[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (const auto & Elem : Right)
-  // CHECK-FIXES-NEXT: constRefArg(Elem);
+  // CHECK-FIXES: for (const auto & I : Right)
+  // CHECK-FIXES-NEXT: constRefArg(I);
 
   // Using as a non-const reference is not.
   for (int I = 0; I < N; ++I) {
     nonConstRefArg(Array[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Array)
-  // CHECK-FIXES-NEXT: nonConstRefArg(Elem);
+  // CHECK-FIXES: for (auto & I : Array)
+  // CHECK-FIXES-NEXT: nonConstRefArg(I);
   for (int I = 0; I < N; ++I) {
     nonConstRefArg(Right[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Right)
-  // CHECK-FIXES-NEXT: nonConstRefArg(Elem);
+  // CHECK-FIXES: for (auto & I : Right)
+  // CHECK-FIXES-NEXT: nonConstRefArg(I);
   for (int I = 0; I < N; ++I) {
     if (OtherRight < Right[I])
       foo();
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Right)
-  // CHECK-FIXES-NEXT: if (OtherRight < Elem)
+  // CHECK-FIXES: for (auto & I : Right)
+  // CHECK-FIXES-NEXT: if (OtherRight < I)
 }
 
 void primitiveTypes() {
@@ -238,17 +238,17 @@ void takingReferences() {
     Str &K = Array[I];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto & Elem : Array)
-  // CHECK-FIXES-NEXT: Str &J = Elem;
-  // CHECK-FIXES-NEXT: Str &K = Elem;
+  // CHECK-FIXES: for (auto & I : Array)
+  // CHECK-FIXES-NEXT: Str &J = I;
+  // CHECK-FIXES-NEXT: Str &K = I;
   for (int I = 0; I < N; ++I) {
     const Str &J = Array[I];
     const Str &K = Array[I];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
-  // CHECK-FIXES: for (auto Elem : Array)
-  // CHECK-FIXES-NEXT: const Str &J = Elem;
-  // CHECK-FIXES-NEXT: const Str &K = Elem;
+  // CHECK-FIXES: for (auto I : Array)
+  // CHECK-FIXES-NEXT: const Str &J = I;
+  // CHECK-FIXES-NEXT: const Str &K = I;
 
   // Primitive type.
   for (int I = 0; I < N; ++I) {
@@ -309,7 +309,7 @@ struct vector {
 };
 
 // If the elements are already constant, we won't do any ImplicitCast to const.
-void testContainerOfConstElements() {
+void testContainerOfConstIents() {
   const int Ints[N]{};
   for (int I = 0; I < N; ++I) {
     OtherInt -= Ints[I];
@@ -348,14 +348,13 @@ class TestInsideConstFunction {
       constRefArg(Array[I]);
     }
     // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
-    // CHECK-FIXES: for (auto Elem : Array)
+    // CHECK-FIXES: for (auto I : Array)
 
     for (int I = 0; I < V.size(); ++I) {
       if (V[I])
         copyArg(V[I]);
     }
     // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
-    // CHECK-FIXES: for (int Elem : V)
-
+    // CHECK-FIXES: for (int I : V)
   }
 };

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp?rev=252308&r1=252307&r2=252308&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp Fri Nov  6 09:03:14 2015
@@ -14,9 +14,9 @@ void f() {
     int B = Arr[I][A];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Arr)
+  // CHECK-FIXES: for (auto & I : Arr)
   // CHECK-FIXES-NEXT: int A = 0;
-  // CHECK-FIXES-NEXT: int B = Elem[A];
+  // CHECK-FIXES-NEXT: int B = I[A];
 
   for (int J = 0; J < M; ++J) {
     int A = 0;
@@ -64,10 +64,10 @@ void aliasing() {
     int Z = Arr[I].X + T.X;
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Arr)
-  // CHECK-FIXES-NEXT: Val &T = Elem;
+  // CHECK-FIXES: for (auto & I : Arr)
+  // CHECK-FIXES-NEXT: Val &T = I;
   // CHECK-FIXES-NEXT: int Y = T.X;
-  // CHECK-FIXES-NEXT: int Z = Elem.X + T.X;
+  // CHECK-FIXES-NEXT: int Z = I.X + T.X;
 
   for (int I = 0; I < N; ++I) {
     Val T = Arr[I];
@@ -75,10 +75,10 @@ void aliasing() {
     int Z = Arr[I].X + T.X;
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Arr)
-  // CHECK-FIXES-NEXT: Val T = Elem;
+  // CHECK-FIXES: for (auto & I : Arr)
+  // CHECK-FIXES-NEXT: Val T = I;
   // CHECK-FIXES-NEXT: int Y = T.X;
-  // CHECK-FIXES-NEXT: int Z = Elem.X + T.X;
+  // CHECK-FIXES-NEXT: int Z = I.X + T.X;
 
   // The same for pseudo-arrays like std::vector<T> (or here dependent<Val>)
   // which provide a subscript operator[].
@@ -108,8 +108,8 @@ void aliasing() {
     int Y = T.X;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Arr)
-  // CHECK-FIXES-NEXT: Val &T = func(Elem);
+  // CHECK-FIXES: for (auto & I : Arr)
+  // CHECK-FIXES-NEXT: Val &T = func(I);
   // CHECK-FIXES-NEXT: int Y = T.X;
 
   int IntArr[N];
@@ -164,8 +164,8 @@ void aliasing() {
     IntRef Int(IntArr[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : IntArr)
-  // CHECK-FIXES-NEXT: IntRef Int(Elem);
+  // CHECK-FIXES: for (int I : IntArr)
+  // CHECK-FIXES-NEXT: IntRef Int(I);
 
   // Ensure that removing the alias doesn't leave empty lines behind.
   for (int I = 0; I < N; ++I) {
@@ -227,8 +227,8 @@ void refs_and_vals() {
     unsigned Othersize = Other.size();
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Dep)
-  // CHECK-FIXES-NEXT: printf("%d\n", Elem);
+  // CHECK-FIXES: for (int & It : Dep)
+  // CHECK-FIXES-NEXT: printf("%d\n", It);
   // CHECK-FIXES-NEXT: const int& Idx = Other[0];
   // CHECK-FIXES-NEXT: unsigned Othersize = Other.size();
 
@@ -307,10 +307,10 @@ void sameNames() {
     (void)Nums[I];
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Nums)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2 + Num;
-  // CHECK-FIXES-NEXT: (void)Elem;
+  // CHECK-FIXES: for (int & I : Nums)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2 + Num;
+  // CHECK-FIXES-NEXT: (void)I;
 
   int Elem = 0;
   for (int I = 0; I < N; ++I) {
@@ -319,10 +319,10 @@ void sameNames() {
     (void)Nums[I];
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & NumsI : Nums)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", NumsI);
-  // CHECK-FIXES-NEXT: Sum += NumsI + 2 + Num + Elem;
-  // CHECK-FIXES-NEXT: (void)NumsI;
+  // CHECK-FIXES: for (int & I : Nums)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2 + Num + Elem;
+  // CHECK-FIXES-NEXT: (void)I;
 }
 
 void oldIndexConflict() {
@@ -349,8 +349,8 @@ void macroConflict() {
     printf("Max of 3 and 5: %d\n", MAX(3, 5));
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : MAXs)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : MAXs)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
   // CHECK-FIXES-NEXT: printf("Max of 3 and 5: %d\n", MAX(3, 5));
 
   for (S::const_iterator It = MAXs.begin(), E = MAXs.end(); It != E; ++It) {
@@ -358,8 +358,8 @@ void macroConflict() {
     printf("Max of 3 and 5: %d\n", MAX(3, 5));
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto Elem : MAXs)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto It : MAXs)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
   // CHECK-FIXES-NEXT: printf("Max of 3 and 5: %d\n", MAX(3, 5));
 
   T DEFs;
@@ -369,9 +369,9 @@ void macroConflict() {
     }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : DEFs)
-  // CHECK-FIXES-NEXT: if (Elem == DEF)
-  // CHECK-FIXES-NEXT: printf("I found %d\n", Elem);
+  // CHECK-FIXES: for (int & It : DEFs)
+  // CHECK-FIXES-NEXT: if (It == DEF)
+  // CHECK-FIXES-NEXT: printf("I found %d\n", It);
 }
 
 void keywordConflict() {
@@ -380,8 +380,8 @@ void keywordConflict() {
     *It = 5;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : ints)
-  // CHECK-FIXES-NEXT: Elem = 5;
+  // CHECK-FIXES: for (int & It : ints)
+  // CHECK-FIXES-NEXT: It = 5;
 
   U __FUNCTION__s;
   for (U::iterator It = __FUNCTION__s.begin(), E = __FUNCTION__s.end();
@@ -389,8 +389,8 @@ void keywordConflict() {
     int __FUNCTION__s_It = (*It).X + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : __FUNCTION__s)
-  // CHECK-FIXES-NEXT: int __FUNCTION__s_It = Elem.X + 2;
+  // CHECK-FIXES: for (auto & It : __FUNCTION__s)
+  // CHECK-FIXES-NEXT: int __FUNCTION__s_It = It.X + 2;
 }
 
 void typeConflict() {
@@ -408,8 +408,8 @@ void typeConflict() {
     *It = sizeof(Val);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Vals)
-  // CHECK-FIXES-NEXT: Elem = sizeof(Val);
+  // CHECK-FIXES: for (int & It : Vals)
+  // CHECK-FIXES-NEXT: It = sizeof(Val);
 
   typedef struct Val TD;
   U TDs;
@@ -427,7 +427,7 @@ void typeConflict() {
     (void) *It;
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : TDs)
+  // CHECK-FIXES: for (auto & It : TDs)
   // CHECK-FIXES-NEXT: TD V;
   // CHECK-FIXES-NEXT: V.X = 5;
 
@@ -437,8 +437,8 @@ void typeConflict() {
     *It = sizeof(St);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Sts)
-  // CHECK-FIXES-NEXT: Elem = sizeof(St);
+  // CHECK-FIXES: for (int & It : Sts)
+  // CHECK-FIXES-NEXT: It = sizeof(St);
 }
 
 } // namespace NamingConflict
@@ -501,10 +501,10 @@ void f() {
   }
   // CHECK-MESSAGES: :[[@LINE-8]]:3: warning: use range-based for loop instead
   // CHECK-MESSAGES: :[[@LINE-8]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Arr)
-  // CHECK-FIXES-NEXT: for (auto & ArrJ : Arr)
-  // CHECK-FIXES-NEXT: int K = Elem.X + ArrJ.X;
-  // CHECK-FIXES-NOT: int L = Elem.X + Elem.X;
+  // CHECK-FIXES: for (auto & I : Arr)
+  // CHECK-FIXES-NEXT: for (auto & J : Arr)
+  // CHECK-FIXES-NEXT: int K = I.X + J.X;
+  // CHECK-FIXES-NOT: int L = I.X + I.X;
 
   // The inner loop is also convertible, but doesn't need to be converted
   // immediately. FIXME: update this test when that changes.
@@ -515,9 +515,9 @@ void f() {
     }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Nest)
+  // CHECK-FIXES: for (auto & I : Nest)
   // CHECK-FIXES-NEXT: for (int J = 0; J < M; ++J)
-  // CHECK-FIXES-NEXT: printf("Got item %d", Elem[J].X);
+  // CHECK-FIXES-NEXT: printf("Got item %d", I[J].X);
 
   // Note that the order of M and N are switched for this test.
   for (int J = 0; J < M; ++J) {
@@ -528,8 +528,8 @@ void f() {
   // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop instead
   // CHECK-FIXES-NOT: for (auto & {{[a-zA-Z_]+}} : Nest[I])
   // CHECK-FIXES: for (int J = 0; J < M; ++J)
-  // CHECK-FIXES-NEXT: for (auto & Elem : Nest)
-  // CHECK-FIXES-NEXT: printf("Got item %d", Elem[J].X);
+  // CHECK-FIXES-NEXT: for (auto & I : Nest)
+  // CHECK-FIXES-NEXT: printf("Got item %d", I[J].X);
 
   // The inner loop is also convertible.
   Nested<T> NestT;
@@ -539,8 +539,8 @@ void f() {
     }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : NestT)
-  // CHECK-FIXES-NEXT: for (T::iterator TI = Elem.begin(), TE = Elem.end(); TI != TE; ++TI)
+  // CHECK-FIXES: for (auto & I : NestT)
+  // CHECK-FIXES-NEXT: for (T::iterator TI = I.begin(), TE = I.end(); TI != TE; ++TI)
   // CHECK-FIXES-NEXT: printf("%d", *TI);
 
   // The inner loop is also convertible.
@@ -551,8 +551,8 @@ void f() {
     }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto Elem : NestS)
-  // CHECK-FIXES-NEXT: for (S::const_iterator SI = Elem.begin(), SE = Elem.end(); SI != SE; ++SI)
+  // CHECK-FIXES: for (auto I : NestS)
+  // CHECK-FIXES-NEXT: for (S::const_iterator SI = I.begin(), SE = I.end(); SI != SE; ++SI)
   // CHECK-FIXES-NEXT: printf("%d", *SI);
 
   for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
@@ -611,9 +611,9 @@ void complexContainer() {
     MutableVal J = *I;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Exes[Index].getS())
-  // CHECK-FIXES-NEXT: MutableVal K = Elem;
-  // CHECK-FIXES-NEXT: MutableVal J = Elem;
+  // CHECK-FIXES: for (auto & I : Exes[Index].getS())
+  // CHECK-FIXES-NEXT: MutableVal K = I;
+  // CHECK-FIXES-NEXT: MutableVal J = I;
 }
 
 void f() {
@@ -623,24 +623,24 @@ void f() {
     printf("I found %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Tt)
-  // CHECK-FIXES-NEXT: printf("I found %d\n", Elem);
+  // CHECK-FIXES: for (int & It : Tt)
+  // CHECK-FIXES-NEXT: printf("I found %d\n", It);
 
   T *Pt;
   for (T::iterator It = Pt->begin(); It != Pt->end(); ++It) {
     printf("I found %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : *Pt)
-  // CHECK-FIXES-NEXT: printf("I found %d\n", Elem);
+  // CHECK-FIXES: for (int & It : *Pt)
+  // CHECK-FIXES-NEXT: printf("I found %d\n", It);
 
   S Ss;
   for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
     printf("s has value %d\n", (*It).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   S *Ps;
   for (S::iterator It = Ps->begin(); It != Ps->end(); ++It) {
@@ -654,51 +654,51 @@ void f() {
     printf("s has value %d\n", It->X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
     It->X = 3;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: Elem.X = 3;
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: It.X = 3;
 
   for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
     (*It).X = 3;
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: Elem.X = 3;
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: It.X = 3;
 
   for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
     It->nonConstFun(4, 5);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
-  // CHECK-FIXES-NEXT: Elem.nonConstFun(4, 5);
+  // CHECK-FIXES: for (auto & It : Ss)
+  // CHECK-FIXES-NEXT: It.nonConstFun(4, 5);
 
   U Uu;
   for (U::iterator It = Uu.begin(); It != Uu.end(); ++It) {
     printf("s has value %d\n", It->X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Uu)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Uu)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   for (U::iterator It = Uu.begin(); It != Uu.end(); ++It) {
     printf("s has value %d\n", (*It).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Uu)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto & It : Uu)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   U::iterator A;
   for (U::iterator I = Uu.begin(); I != Uu.end(); ++I)
     int K = A->X + I->X;
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Uu)
-  // CHECK-FIXES-NEXT: int K = A->X + Elem.X;
+  // CHECK-FIXES: for (auto & I : Uu)
+  // CHECK-FIXES-NEXT: int K = A->X + I.X;
 
   dependent<int> V;
   for (dependent<int>::iterator It = V.begin();
@@ -706,16 +706,16 @@ void f() {
     printf("Fibonacci number is %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
+  // CHECK-FIXES: for (int & It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   for (dependent<int>::iterator It(V.begin());
        It != V.end(); ++It) {
     printf("Fibonacci number is %d\n", *It);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
+  // CHECK-FIXES: for (int & It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   doublyDependent<int, int> intmap;
   for (doublyDependent<int, int>::iterator It = intmap.begin();
@@ -723,8 +723,8 @@ void f() {
     printf("intmap[%d] = %d", It->first, It->second);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : intmap)
-  // CHECK-FIXES-NEXT: printf("intmap[%d] = %d", Elem.first, Elem.second);
+  // CHECK-FIXES: for (auto & It : intmap)
+  // CHECK-FIXES-NEXT: printf("intmap[%d] = %d", It.first, It.second);
 }
 
 void different_type() {
@@ -738,8 +738,8 @@ void different_type() {
     printf("s has value %d\n", (*It).X);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto Elem : Ss)
-  // CHECK-FIXES-NEXT: printf("s has value %d\n", Elem.X);
+  // CHECK-FIXES: for (auto It : Ss)
+  // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
 
   S *Ps;
   for (S::const_iterator It = Ps->begin(); It != Ps->end(); ++It) {
@@ -778,8 +778,8 @@ void messing_with_macros() {
     printf("Value: %d\n", Arr[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT:  printf("Value: %d\n", Elem);
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT:  printf("Value: %d\n", I);
 
   for (int I = 0; I < N; ++I) {
     printf("Value: %d\n", CONT Arr[I]);
@@ -791,9 +791,9 @@ void messing_with_macros() {
     THREE_PARAM(Arr[I], Arr[I], Arr[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Arr)
-  // CHECK-FIXES-NEXT: TWO_PARAM(Elem, Elem);
-  // CHECK-FIXES-NEXT: THREE_PARAM(Elem, Elem, Elem);
+  // CHECK-FIXES: for (int & I : Arr)
+  // CHECK-FIXES-NEXT: TWO_PARAM(I, I);
+  // CHECK-FIXES-NEXT: THREE_PARAM(I, I, I);
 }
 
 } // namespace Macros
@@ -811,7 +811,7 @@ void set_union(Container &container) {
   for (S::iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI)
     (void) *SI;
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & Elem : Ss)
+  // CHECK-FIXES: for (auto & SI : Ss)
 }
 
 void template_instantiation() {
@@ -832,43 +832,43 @@ void capturesIndex() {
   for (int I = 0; I < N; ++I)
     auto F1 = [Arr, I]() { int R1 = Arr[I] + 1; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: auto F1 = [Arr, &Elem]() { int R1 = Elem + 1; };
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: auto F1 = [Arr, &I]() { int R1 = I + 1; };
 
   for (int I = 0; I < N; ++I)
     auto F2 = [Arr, &I]() { int R2 = Arr[I] + 3; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: auto F2 = [Arr, &Elem]() { int R2 = Elem + 3; };
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: auto F2 = [Arr, &I]() { int R2 = I + 3; };
 
   // FIXME: alias don't work if the index is captured.
   // Alias declared inside lambda (by value).
   for (int I = 0; I < N; ++I)
     auto F3 = [&Arr, I]() { int R3 = Arr[I]; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: auto F3 = [&Arr, &Elem]() { int R3 = Elem; };
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: auto F3 = [&Arr, &I]() { int R3 = I; };
 
 
   for (int I = 0; I < N; ++I)
     auto F4 = [&Arr, &I]() { int R4 = Arr[I]; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: auto F4 = [&Arr, &Elem]() { int R4 = Elem; };
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: auto F4 = [&Arr, &I]() { int R4 = I; };
 
   // Alias declared inside lambda (by reference).
   for (int I = 0; I < N; ++I)
     auto F5 = [&Arr, I]() { int &R5 = Arr[I]; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Arr)
-  // CHECK-FIXES-NEXT: auto F5 = [&Arr, &Elem]() { int &R5 = Elem; };
+  // CHECK-FIXES: for (int & I : Arr)
+  // CHECK-FIXES-NEXT: auto F5 = [&Arr, &I]() { int &R5 = I; };
 
 
   for (int I = 0; I < N; ++I)
     auto F6 = [&Arr, &I]() { int &R6 = Arr[I]; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Arr)
-  // CHECK-FIXES-NEXT: auto F6 = [&Arr, &Elem]() { int &R6 = Elem; };
+  // CHECK-FIXES: for (int & I : Arr)
+  // CHECK-FIXES-NEXT: auto F6 = [&Arr, &I]() { int &R6 = I; };
 
   for (int I = 0; I < N; ++I) {
     auto F = [Arr, I](int k) {
@@ -877,10 +877,10 @@ void capturesIndex() {
     F(Arr[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: auto F = [Arr, &Elem](int k)
-  // CHECK-FIXES-NEXT: printf("%d\n", Elem + k);
-  // CHECK-FIXES: F(Elem);
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: auto F = [Arr, &I](int k)
+  // CHECK-FIXES-NEXT: printf("%d\n", I + k);
+  // CHECK-FIXES: F(I);
 }
 
 void implicitCapture() {
@@ -909,10 +909,10 @@ void implicitCapture() {
     };
   }
   // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
+  // CHECK-FIXES: for (int I : Arr)
   // CHECK-FIXES-NEXT: auto G3 = [&]()
-  // CHECK-FIXES-NEXT: int R3 = Elem;
-  // CHECK-FIXES-NEXT: int J3 = Elem + R3;
+  // CHECK-FIXES-NEXT: int R3 = I;
+  // CHECK-FIXES-NEXT: int J3 = I + R3;
 
   for (int I = 0; I < N; ++I) {
     auto G4 = [=]() {
@@ -920,9 +920,9 @@ void implicitCapture() {
     };
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
+  // CHECK-FIXES: for (int I : Arr)
   // CHECK-FIXES-NEXT: auto G4 = [=]()
-  // CHECK-FIXES-NEXT: int R4 = Elem + 5;
+  // CHECK-FIXES-NEXT: int R4 = I + 5;
 
   // Alias by value.
   for (int I = 0; I < N; ++I) {
@@ -955,14 +955,14 @@ void iterators() {
   for (dependent<int>::iterator I = Dep.begin(), E = Dep.end(); I != E; ++I)
     auto H1 = [&I]() { int R = *I; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Dep)
-  // CHECK-FIXES-NEXT: auto H1 = [&Elem]() { int R = Elem; };
+  // CHECK-FIXES: for (int & I : Dep)
+  // CHECK-FIXES-NEXT: auto H1 = [&I]() { int R = I; };
 
   for (dependent<int>::iterator I = Dep.begin(), E = Dep.end(); I != E; ++I)
     auto H2 = [&]() { int R = *I + 2; };
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & Elem : Dep)
-  // CHECK-FIXES-NEXT: auto H2 = [&]() { int R = Elem + 2; };
+  // CHECK-FIXES: for (int & I : Dep)
+  // CHECK-FIXES-NEXT: auto H2 = [&]() { int R = I + 2; };
 
   // FIXME: It doesn't work with const iterators.
   for (dependent<int>::const_iterator I = Dep.begin(), E = Dep.end();
@@ -991,15 +991,15 @@ void captureByValue() {
     auto C1 = [&Arr, I]() { if (Arr[I] == 1); };
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: auto C1 = [&Arr, &Elem]() { if (Elem == 1); };
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: auto C1 = [&Arr, &I]() { if (I == 1); };
 
   for (unsigned I = 0; I < Dep.size(); ++I) {
     auto C2 = [&Dep, I]() { if (Dep[I] == 2); };
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Dep)
-  // CHECK-FIXES-NEXT: auto C2 = [&Dep, &Elem]() { if (Elem == 2); };
+  // CHECK-FIXES: for (int I : Dep)
+  // CHECK-FIXES-NEXT: auto C2 = [&Dep, &I]() { if (I == 2); };
 }
 
 } // namespace Lambdas
@@ -1024,12 +1024,12 @@ void f() {
     E Ee{ { { g( { Array[I] } ) } } };
   }
   // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Array)
-  // CHECK-FIXES-NEXT: int A{ Elem };
-  // CHECK-FIXES-NEXT: int B{ g(Elem) };
-  // CHECK-FIXES-NEXT: int C{ g( { Elem } ) };
-  // CHECK-FIXES-NEXT: D Dd{ { g( { Elem } ) } };
-  // CHECK-FIXES-NEXT: E Ee{ { { g( { Elem } ) } } };
+  // CHECK-FIXES: for (int I : Array)
+  // CHECK-FIXES-NEXT: int A{ I };
+  // CHECK-FIXES-NEXT: int B{ g(I) };
+  // CHECK-FIXES-NEXT: int C{ g( { I } ) };
+  // CHECK-FIXES-NEXT: D Dd{ { g( { I } ) } };
+  // CHECK-FIXES-NEXT: E Ee{ { { g( { I } ) } } };
 }
 
 } // namespace InitLists

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp?rev=252308&r1=252307&r2=252308&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp Fri Nov  6 09:03:14 2015
@@ -14,8 +14,8 @@ void naming() {
     printf("%d\n", arr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int elem : arr)
-  // CHECK-FIXES-NEXT: printf("%d\n", elem);
+  // CHECK-FIXES: for (int i : arr)
+  // CHECK-FIXES-NEXT: printf("%d\n", i);
 
   for (int i = 0; i < n; ++i) {
     printf("%d\n", nums[i]);
@@ -36,50 +36,6 @@ void naming() {
     printf("%d\n", nums[i] + num);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int elem : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", elem + num);
-
-  int elem = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int nums_i : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", nums_i + num + elem);
-
-  int nums_i = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem + nums_i);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int nums_elem : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", nums_elem + num + elem + nums_i);
-
-  int nums_elem = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem + nums_i + nums_elem);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int give_me_name_0 : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", give_me_name_0 + num + elem + nums_i + nums_elem);
-
-  int give_me_name_0 = 0;
-  for (int i = 0; i < n; ++i) {
-    printf("%d\n", nums[i] + num + elem + nums_i + nums_elem + give_me_name_0);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int give_me_name_1 : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", give_me_name_1 + num + elem + nums_i + nums_elem + give_me_name_0);
-
-  int nums_j = 0;
-  for (int i = 0; i < n; ++i) {
-    for (int j = 0; j < n; ++j) {
-      printf("%d\n", nums[i] + nums[j] + num + elem + nums_i + nums_j + nums_elem);
-    }
-  }
-  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int give_me_name_0 : nums)
-  // CHECK-FIXES: for (int give_me_name_1 : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", give_me_name_0 + give_me_name_1 + num + elem + nums_i + nums_j + nums_elem);
+  // CHECK-FIXES: for (int i : nums)
+  // CHECK-FIXES-NEXT: printf("%d\n", i + num);
 }

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp?rev=252308&r1=252307&r2=252308&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp Fri Nov  6 09:03:14 2015
@@ -14,8 +14,8 @@ void naming() {
     printf("%d\n", ARR[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int ELEM : ARR)
-  // CHECK-FIXES-NEXT: printf("%d\n", ELEM);
+  // CHECK-FIXES: for (int I : ARR)
+  // CHECK-FIXES-NEXT: printf("%d\n", I);
 
   for (int I = 0; I < N; ++I) {
     printf("%d\n", NUMS[I]);
@@ -36,50 +36,6 @@ void naming() {
     printf("%d\n", NUMS[I] + NUM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int ELEM : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", ELEM + NUM);
-
-  int ELEM = 0;
-  for (int I = 0; I < N; ++I) {
-    printf("%d\n", NUMS[I] + NUM + ELEM);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int NUMS_I : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", NUMS_I + NUM + ELEM);
-
-  int NUMS_I = 0;
-  for (int I = 0; I < N; ++I) {
-    printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int NUMS_ELEM : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", NUMS_ELEM + NUM + ELEM + NUMS_I);
-
-  int NUMS_ELEM = 0;
-  for (int I = 0; I < N; ++I) {
-    printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int GIVE_ME_NAME_0 : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + NUM + ELEM + NUMS_I + NUMS_ELEM);
-
-  int GIVE_ME_NAME_0 = 0;
-  for (int I = 0; I < N; ++I) {
-    printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int GIVE_ME_NAME_1 : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
-
-  int NUMS_J = 0;
-  for (int I = 0; I < N; ++I) {
-    for (int J = 0; J < N; ++J) {
-      printf("%d\n", NUMS[I] + NUMS[J] + NUM + ELEM + NUMS_I + NUMS_J + NUMS_ELEM);
-    }
-  }
-  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int GIVE_ME_NAME_0 : NUMS)
-  // CHECK-FIXES: for (int GIVE_ME_NAME_1 : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_J + NUMS_ELEM);
+  // CHECK-FIXES: for (int I : NUMS)
+  // CHECK-FIXES-NEXT: printf("%d\n", I + NUM);
 }




More information about the cfe-commits mailing list