summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp
diff options
context:
space:
mode:
authorAngel Garcia Gomez <angelgarcia@google.com>2015-10-30 09:37:57 +0000
committerAngel Garcia Gomez <angelgarcia@google.com>2015-10-30 09:37:57 +0000
commit68175a02fbc35f5249218b2b3ac81fae9a9ec085 (patch)
tree97429f9fe103e3959be99e0f046c87721d2d2f6f /clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp
parent4647ed74acc039233d23981cea56666f5f8c619f (diff)
downloadbcm5719-llvm-68175a02fbc35f5249218b2b3ac81fae9a9ec085.tar.gz
bcm5719-llvm-68175a02fbc35f5249218b2b3ac81fae9a9ec085.zip
Only copy small types in modernize-loop-convert.
Summary: If the size of the type is above a certain bound, we'll take a const reference. This bound can be set as an option. For now, the default value is 16 bytes. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D14176 llvm-svn: 251694
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp
index f98795f82f9..13a8226d18f 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -113,6 +113,14 @@ const int *constArray() {
// CHECK-FIXES: for (const auto & Elem : NonCopy)
// CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem.X, Elem.X + Elem.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);
+
bool Something = false;
for (int I = 0; I < N; ++I) {
if (Something)
OpenPOWER on IntegriCloud