================
@@ -357,6 +372,51 @@ std::string lambda() {
   }();
 }
 
+namespace overload_funcs {
+std::string dbl2str(double f);
+// Skip overloaded functions
+std::string overload(int) { return "int"; }
+// Because of this overload (non-literal return) the fix should not be applied
+std::string overload(double f) { return "f=" + dbl2str(f); }
+std::string overload(std::string) { return "string"; }
+}
+
+namespace overload_methods {
+struct Foo {
+  // Skip overloaded methods
+  std::string overload(int) { return "int"; }
+  std::string overload(double f) { return "double"; }
+  std::string overload(std::string) { return "string"; }
+};
+}
+
+namespace overload_methods_nested_classes {
+struct Bar {
+  std::string overload(int) { return "int"; }
+  std::string overload(std::string) { return "string"; }
+
+  struct FooBar {
+    std::string overload(char*) { return "char*"; }
+    std::string overload(double f) { return "double"; }
+  };
+};
+}
+
+namespace overload_methods_nested_namespaces {
+namespace foo {
+  std::string overload(int) { return "int"; }
+  std::string overload(std::string) { return "string"; }
+}
+using foo::overload;
+std::string overload(char*) { return "char*"; }
+}
+
+namespace overload_methods_templated {
+    template <typename T>
+    std::string overload(T value) { return "T";}
+    std::string overload(int value) { return "int"; }
+}
----------------
vbvictor wrote:

```cpp

namespace overload_nested_no_using {
namespace outer {
std::string foo(int);
std::string foo(double);
}
namespace inner {
std::string foo(double) { return "double"; }
// CHECK-MESSAGES:[[@LINE-1]]:1: warning: consider using 'std::string_view' to 
avoid unnecessary copying and allocations [modernize-use-string-view]
// CHECK-FIXES: std::string_view foo(double) { return "double"; }
}
}

namespace overload_nested_using_decl {
namespace outer {
std::string foo(int);
}
namespace inner {
using outer::foo;
std::string foo(double) { return "double"; }
// No warning: lookup finds UsingShadowDecl + FunctionDecl.
}
}

namespace overload_nested_using_directive {
namespace outer {
std::string foo(int);
std::string foo(double);
}
namespace inner {
using namespace outer;
std::string foo(char*) { return "char*"; }
// CHECK-MESSAGES:[[@LINE-1]]:1: warning: consider using 'std::string_view' to 
avoid unnecessary copying and allocations [modernize-use-string-view]
// CHECK-FIXES: std::string_view foo(char*) { return "char*"; }
}
}

```

https://github.com/llvm/llvm-project/pull/183921
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to