malcolm.parsons created this revision. Herald added a subscriber: JDevlieghere.
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. https://reviews.llvm.org/D29018 Files: clang-tidy/performance/UnnecessaryValueParamCheck.cpp test/clang-tidy/performance-unnecessary-value-param.cpp Index: test/clang-tidy/performance-unnecessary-value-param.cpp =================================================================== --- test/clang-tidy/performance-unnecessary-value-param.cpp +++ test/clang-tidy/performance-unnecessary-value-param.cpp @@ -320,3 +320,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); +} Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp =================================================================== --- clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ 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);
Index: test/clang-tidy/performance-unnecessary-value-param.cpp =================================================================== --- test/clang-tidy/performance-unnecessary-value-param.cpp +++ test/clang-tidy/performance-unnecessary-value-param.cpp @@ -320,3 +320,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); +} Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp =================================================================== --- clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ 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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits