[clang-tidy] Ignore implicit functions in performance-unnecessary-value-param

Summary:
The performance-unnecessary-value-param check mangled inherited
constructors, as the constructors' parameters do not have useful source
locations. Fix this by ignoring implicit functions.

Fixes PR31684.

Reviewers: flx, alexfh, aaron.ballman

Subscribers: madsravn, JDevlieghere, cfe-commits

Differential Revision: https://reviews.llvm.org/D29018

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@292786 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
index 4c12318..cde30a6 100644
--- a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -74,7 +74,7 @@
   Finder->addMatcher(
       functionDecl(hasBody(stmt()), isDefinition(),
                    unless(cxxMethodDecl(anyOf(isOverride(), isFinal()))),
-                   unless(isInstantiated()),
+                   unless(anyOf(isInstantiated(), isImplicit())),
                    has(typeLoc(forEach(ExpensiveValueParamDecl))),
                    decl().bind("functionDecl")),
       this);
diff --git a/test/clang-tidy/performance-unnecessary-value-param.cpp b/test/clang-tidy/performance-unnecessary-value-param.cpp
index dfd545a..5491cbb 100644
--- a/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ b/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -331,3 +331,20 @@
 struct NegativeFinalImpl : public NegativeDependentTypeInterface<T> {
   void Method(ExpensiveToCopyType E) final {}
 };
+
+struct PositiveConstructor {
+  PositiveConstructor(ExpensiveToCopyType E) : E(E) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:43: warning: the parameter 'E' is copied
+  // CHECK-FIXES: PositiveConstructor(const ExpensiveToCopyType& E) : E(E) {}
+
+  ExpensiveToCopyType E;
+};
+
+struct NegativeUsingConstructor : public PositiveConstructor {
+  using PositiveConstructor::PositiveConstructor;
+};
+
+void fun() {
+  ExpensiveToCopyType E;
+  NegativeUsingConstructor S(E);
+}