summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp
diff options
context:
space:
mode:
authorAngel Garcia Gomez <angelgarcia@google.com>2015-11-02 17:02:52 +0000
committerAngel Garcia Gomez <angelgarcia@google.com>2015-11-02 17:02:52 +0000
commit5daa9b231f5ba14ee8dd902260c8edae13cc01de (patch)
treec0381867f9e3b8b561140bdae71d48f06e2104d1 /clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp
parentff11a44fe015732132f0d3e130c503ebfba86a80 (diff)
downloadbcm5719-llvm-5daa9b231f5ba14ee8dd902260c8edae13cc01de.tar.gz
bcm5719-llvm-5daa9b231f5ba14ee8dd902260c8edae13cc01de.zip
Make the modernize-loop-convert's const-detection smarter.
Summary: Now, it detects that several kinds of usages are can't modify the elements. Examples: -When an usage is a call to a const member function or operator of the element. -If the element is used as an argument to a function or constructor that takes a const-reference or a value. -LValue to RValue conversion, if the element is a fundamental type (which allows the use of most of the builtin operators). Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D14198 llvm-svn: 251808
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp
index 3408488a9c4..c8e5c10d11a 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-camelback.cpp
@@ -13,14 +13,14 @@ 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: for (int elem : arr)
// CHECK-FIXES-NEXT: printf("%d\n", elem);
for (int i = 0; i < n; ++i) {
printf("%d\n", nums[i]);
}
// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & num : nums)
+ // CHECK-FIXES: for (int num : nums)
// CHECK-FIXES-NEXT: printf("%d\n", num);
int num = 0;
@@ -28,7 +28,7 @@ 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: for (int elem : nums)
// CHECK-FIXES-NEXT: printf("%d\n", elem + num);
int elem = 0;
@@ -36,7 +36,7 @@ void naming() {
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: for (int numsI : nums)
// CHECK-FIXES-NEXT: printf("%d\n", numsI + num + elem);
int numsI = 0;
@@ -44,7 +44,7 @@ void naming() {
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: for (int numsElem : nums)
// CHECK-FIXES-NEXT: printf("%d\n", numsElem + num + elem + numsI);
int numsElem = 0;
@@ -52,7 +52,7 @@ void naming() {
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: for (int giveMeName0 : nums)
// CHECK-FIXES-NEXT: printf("%d\n", giveMeName0 + num + elem + numsI + numsElem);
int giveMeName0 = 0;
@@ -60,7 +60,7 @@ void naming() {
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: for (int giveMeName1 : nums)
// CHECK-FIXES-NEXT: printf("%d\n", giveMeName1 + num + elem + numsI + numsElem + giveMeName0);
int numsJ = 0;
@@ -71,7 +71,7 @@ void naming() {
}
// 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: for (int giveMeName0 : nums)
+ // CHECK-FIXES: for (int giveMeName1 : nums)
// CHECK-FIXES-NEXT: printf("%d\n", giveMeName0 + giveMeName1 + num + elem + numsI + numsJ + numsElem);
}
OpenPOWER on IntegriCloud