[clang-tools-extra] [clang] [clang-tidy] Handle C++ structured bindings in `performance-for-range-copy` (PR #77105)

Felix Berger via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 08:12:51 PST 2024


================
@@ -234,6 +239,22 @@ void positiveOnlyAccessedFieldAsConst() {
   }
 }
 
+void positiveOnlyAccessedFieldAsConstBinding() {
+  for (auto [X, Y] : View<Iterator<Point>>()) {
+    // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but
+    // CHECK-FIXES: for (const auto& [X, Y] : View<Iterator<Point>>()) {
+    use(X);
+    use(Y);
+  }
+}
+
+void negativeOnlyAccessedFieldAsConstBinding() {
----------------
fberger wrote:

Same here: Can we just have "mutated" in the function name?

https://github.com/llvm/llvm-project/pull/77105


More information about the cfe-commits mailing list