forked from OSchip/llvm-project
[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:
parent
e33d2ce8e3
commit
3de05a2fda
|
@ -74,7 +74,7 @@ void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
|
||||||
Finder->addMatcher(
|
Finder->addMatcher(
|
||||||
functionDecl(hasBody(stmt()), isDefinition(),
|
functionDecl(hasBody(stmt()), isDefinition(),
|
||||||
unless(cxxMethodDecl(anyOf(isOverride(), isFinal()))),
|
unless(cxxMethodDecl(anyOf(isOverride(), isFinal()))),
|
||||||
unless(isInstantiated()),
|
unless(anyOf(isInstantiated(), isImplicit())),
|
||||||
has(typeLoc(forEach(ExpensiveValueParamDecl))),
|
has(typeLoc(forEach(ExpensiveValueParamDecl))),
|
||||||
decl().bind("functionDecl")),
|
decl().bind("functionDecl")),
|
||||||
this);
|
this);
|
||||||
|
|
|
@ -331,3 +331,20 @@ template <typename T>
|
||||||
struct NegativeFinalImpl : public NegativeDependentTypeInterface<T> {
|
struct NegativeFinalImpl : public NegativeDependentTypeInterface<T> {
|
||||||
void Method(ExpensiveToCopyType E) final {}
|
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue