From 68175a02fbc35f5249218b2b3ac81fae9a9ec085 Mon Sep 17 00:00:00 2001 From: Angel Garcia Gomez Date: Fri, 30 Oct 2015 09:37:57 +0000 Subject: 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 --- .../test/clang-tidy/modernize-loop-convert-basic.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang-tools-extra/test/clang-tidy/modernize-loop-convert-basic.cpp') 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) -- cgit v1.2.3