[clang-tools-extra] [clang-tidy] suggest fix it hints for string concat (PR #188430)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 25 06:00:10 PDT 2026


================
@@ -14,18 +14,28 @@ int main() {
     f(mystr1 + mystr2 + mystr1);
     // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead
     mystr1 = mystr1 + mystr2;
-    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
+    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: string concatenation
+    // CHECK-FIXES:    mystr1 += mystr2;
     mystr1 = mystr2 + mystr2 + mystr2;
-    // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: string concatenation
+    // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: string concatenation   
----------------
zeyi2 wrote:

Please remove the trailing whitespaces, same as elsewhere.

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


More information about the cfe-commits mailing list