[clang-tools-extra] [clang-tidy] Fix false negative in performance-inefficient-vector-ope… (PR #179484)

via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 3 07:54:52 PST 2026


================
@@ -424,3 +424,16 @@ void f(std::vector<int>& t) {
 }
 
 } // namespace gh95596
+
+void multiple_statements_in_loop() {
+  std::vector<int> v1;
+  std::vector<int> v2;
+  // CHECK-FIXES: v1.reserve(10);
+  // CHECK-FIXES: v2.reserve(10);
+  for (int i = 0; i < 10; ++i) {
+    v1.push_back(i);
+    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'push_back' is called inside a loop
+    v2.push_back(i);
+    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'push_back' is called inside a loop
+  }
+}
----------------
zeyi2 wrote:

Please add newline at EOF

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


More information about the cfe-commits mailing list