[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

llvm-svn: 292786
This commit is contained in:
Malcolm Parsons 2017-01-23 13:18:08 +00:00
parent e33d2ce8e3
commit 3de05a2fda
2 changed files with 18 additions and 1 deletions

View File

@ -74,7 +74,7 @@ void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
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);

View File

@ -331,3 +331,20 @@ template <typename T>
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);
}