[clang-tools-extra] [clang-tidy] Reland "An option for conditional skipping overloaded functions in modernize-use-string-view" (PR #196387)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Fri May 8 00:18:41 PDT 2026


================
@@ -0,0 +1,147 @@
+// RUN: %check_clang_tidy -check-suffix=DONTCHECK \
+// RUN: -std=c++20-or-later %s modernize-use-string-view %t -- \
+// RUN: --config="{CheckOptions: {modernize-use-string-view.CheckOverloadedFunctions: false}}"
+
+// RUN: %check_clang_tidy -check-suffix=CHECK \
+// RUN: -std=c++20-or-later %s modernize-use-string-view %t -- \
+// RUN: --config="{CheckOptions: {modernize-use-string-view.CheckOverloadedFunctions: true}}"
+
+#include <string>
+#include <utility>
+
+namespace overload_funcs_redeclared {
+std::basic_string<char> overload(int);
+std::string overload(int);
+std::string overload(int) { return "int"; }
+// CHECK-MESSAGES-DONTCHECK:[[@LINE-1]]:1: warning: consider using 'std::string_view' to avoid unnecessary copying and allocations [modernize-use-string-view]
+// CHECK-MESSAGES-CHECK:[[@LINE-2]]:1: warning: consider using 'std::string_view' to avoid unnecessary copying and allocations [modernize-use-string-view]
----------------
zeyi2 wrote:

Small nit:
```suggestion
// CHECK-MESSAGES-CHECK:[[@LINE-2]]:1: warning: consider using 'std::string_view' to avoid unnecessary copying and allocations
```

Same as below :)

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


More information about the cfe-commits mailing list