summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/performance-for-range-copy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/performance-for-range-copy.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/performance-for-range-copy.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/performance-for-range-copy.cpp b/clang-tools-extra/test/clang-tidy/performance-for-range-copy.cpp
index 88ec45b2ddf..1c77996c6ca 100644
--- a/clang-tools-extra/test/clang-tidy/performance-for-range-copy.cpp
+++ b/clang-tools-extra/test/clang-tidy/performance-for-range-copy.cpp
@@ -117,6 +117,11 @@ struct Mutable {
~Mutable() {}
};
+struct Point {
+ ~Point() {}
+ int x, y;
+};
+
Mutable& operator<<(Mutable &Out, bool B) {
Out.setBool(B);
return Out;
@@ -214,6 +219,15 @@ void positiveOnlyUsedAsConstArguments() {
}
}
+void positiveOnlyAccessedFieldAsConst() {
+ for (auto UsedAsConst : View<Iterator<Point>>()) {
+ // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
+ // CHECK-FIXES: for (const auto& UsedAsConst : View<Iterator<Point>>()) {
+ use(UsedAsConst.x);
+ use(UsedAsConst.y);
+ }
+}
+
void positiveOnlyUsedInCopyConstructor() {
for (auto A : View<Iterator<Mutable>>()) {
// CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
OpenPOWER on IntegriCloud