[clang-tools-extra] r292786 - [clang-tidy] Ignore implicit functions in performance-unnecessary-value-param
Malcolm Parsons via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 23 05:18:09 PST 2017
Author: malcolm.parsons
Date: Mon Jan 23 07:18:08 2017
New Revision: 292786
URL: http://llvm.org/viewvc/llvm-project?rev=292786&view=rev
Log:
[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
Modified:
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
Modified: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=292786&r1=292785&r2=292786&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp Mon Jan 23 07:18:08 2017
@@ -74,7 +74,7 @@ void UnnecessaryValueParamCheck::registe
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);
Modified: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=292786&r1=292785&r2=292786&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Mon Jan 23 07:18:08 2017
@@ -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);
+}
More information about the cfe-commits
mailing list