[clang-tools-extra] [clang-tidy] Skip overloaded functions in modernize-use-string-view (PR #183921)

Zinovy Nis via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 7 01:38:35 PST 2026


================
@@ -21,6 +21,29 @@ using namespace clang::ast_matchers;
 
 namespace clang::tidy::modernize {
 
+namespace {
+AST_MATCHER(FunctionDecl, isOverloaded) {
+  const DeclarationName Name = Node.getDeclName();
+  // Skip lambda-like functions
+  if (Name.isEmpty())
+    return false;
+  const DeclContext *DC = Node.getDeclContext();
+  auto LookupResult = DC->lookup(Name);
+  size_t UniqueSignatures = 0;
+  llvm::SmallPtrSet<const FunctionDecl *, 2> SeenFunctions;
+  for (NamedDecl *ND : LookupResult) {
+    if (const auto *FD = dyn_cast<FunctionDecl>(ND)) {
----------------
irishrover wrote:

Sorry, I did not understand the case. Do you mean something like

```
double overload;
std::string overload(int) { return "int"; }
std::string overload(std::string) { return "string"; }
```
? But it has invalid syntax.

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


More information about the cfe-commits mailing list