[PATCH] D12361: LoopConvert no longer take as alias references to other containers.
Angel Garcia via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 26 07:43:46 PDT 2015
angelgarcia created this revision.
angelgarcia added a reviewer: alexfh.
angelgarcia added subscribers: cfe-commits, klimek.
Fix a bug where modernize-loop-convert check would take as alias a reference to other containers. Add the pertinent test.
http://reviews.llvm.org/D12361
Files:
clang-tidy/modernize/LoopConvertUtils.cpp
test/clang-tidy/modernize-loop-convert-extra.cpp
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===================================================================
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -202,6 +202,16 @@
// 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
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===================================================================
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -363,7 +363,7 @@
return isDereferenceOfOpCall(OpCall, IndexVar);
if (OpCall->getOperator() == OO_Subscript) {
assert(OpCall->getNumArgs() == 2);
- return true;
+ return isIndexInSubscriptExpr(OpCall->getArg(1), IndexVar);
}
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12361.33198.patch
Type: text/x-patch
Size: 1277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150826/00a17cb8/attachment.bin>
More information about the cfe-commits
mailing list