[clang-tools-extra] [clang-tidy] Teach `performance-faster-string-find` about `operator+=` (PR #182697)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 21 11:33:06 PST 2026
================
@@ -102,6 +103,17 @@ void StringFind() {
Str.contains("a");
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: 'contains' called with a
// CHECK-FIXES: Str.contains('a');
+ Str += "a";
+ // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'operator+=' called with a
+ // CHECK-FIXES: Str += 'a';
+ ((Str += "a") += "b") += "c";
+ // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'operator+=' called with a
+ // CHECK-MESSAGES: [[@LINE-2]]:20: warning: 'operator+=' called with a
+ // CHECK-MESSAGES: [[@LINE-3]]:28: warning: 'operator+=' called with a
+ // CHECK-FIXES: ((Str += 'a') += 'b') += 'c';
+ Str.operator+=("a");
----------------
localspook wrote:
Not sure who's using this call syntax, but it's very easy to support :shrug:
https://github.com/llvm/llvm-project/pull/182697
More information about the cfe-commits
mailing list