[clang-tools-extra] r246034 - LoopConvert no longer take as alias references to other containers.

Angel Garcia Gomez via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 07:51:12 PDT 2015


Author: angelgarcia
Date: Wed Aug 26 09:51:11 2015
New Revision: 246034

URL: http://llvm.org/viewvc/llvm-project?rev=246034&view=rev
Log:
LoopConvert no longer take as alias references to other containers.

Summary: Fix a bug where modernize-loop-convert check would take as alias a reference to other containers. Add the pertinent test.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

Modified:
    clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.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=246034&r1=246033&r2=246034&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Wed Aug 26 09:51:11 2015
@@ -363,7 +363,7 @@ static bool isAliasDecl(const Decl *TheD
       return isDereferenceOfOpCall(OpCall, IndexVar);
     if (OpCall->getOperator() == OO_Subscript) {
       assert(OpCall->getNumArgs() == 2);
-      return true;
+      return isIndexInSubscriptExpr(OpCall->getArg(1), IndexVar);
     }
     break;
   }

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=246034&r1=246033&r2=246034&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 Wed Aug 26 09:51:11 2015
@@ -202,6 +202,16 @@ void refs_and_vals() {
   // CHECK-FIXES-NOT: MutableVal &{{[a-z_]+}} =
   // CHECK-FIXES: {}
   // CHECK-FIXES-NEXT: alias.x = 0;
+
+  dependent<int> dep, other;
+  for (dependent<int>::iterator it = dep.begin(), e = dep.end(); it != e; ++it) {
+    printf("%d\n", *it);
+    const int& idx = other[0];
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & elem : dep)
+  // CHECK-FIXES-NEXT: printf("%d\n", elem);
+  // CHECK-FIXES-NEXT: const int& idx = other[0];
 }
 
 } // namespace NamingAlias




More information about the cfe-commits mailing list