diff options
author | Malcolm Parsons <malcolm.parsons@gmail.com> | 2017-01-03 12:10:44 +0000 |
---|---|---|
committer | Malcolm Parsons <malcolm.parsons@gmail.com> | 2017-01-03 12:10:44 +0000 |
commit | cfa7d3748e4c774d325cf0f10518ae9307f8d1ea (patch) | |
tree | 035c1b623d62afa2cc93e8cfe3a0835a0a66007c /clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp | |
parent | 009978b4d7d75fd692f7dd44394fe8077893377e (diff) | |
download | bcm5719-llvm-cfa7d3748e4c774d325cf0f10518ae9307f8d1ea.tar.gz bcm5719-llvm-cfa7d3748e4c774d325cf0f10518ae9307f8d1ea.zip |
[clang-tidy] Handle constructors in performance-unnecessary-value-param
Summary:
modernize-pass-by-value doesn't warn about value parameters that
cannot be moved, so performance-unnecessary-value-param should.
Reviewers: aaron.ballman, flx, alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D28022
llvm-svn: 290883
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp b/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp index a712305dd15..623bf8b3082 100644 --- a/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp +++ b/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp @@ -64,6 +64,7 @@ void positiveAndNegative(const ExpensiveToCopyType ConstCopy, const ExpensiveToC struct PositiveConstValueConstructor { PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {} // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy' + // CHECK-FIXES: PositiveConstValueConstructor(const ExpensiveToCopyType& ConstCopy) {} }; template <typename T> void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) { @@ -125,8 +126,17 @@ void negativeValueNonConstMethodIsCalled(ExpensiveToCopyType Obj) { Obj.nonConstMethod(); } -struct NegativeValueCopyConstructor { - NegativeValueCopyConstructor(ExpensiveToCopyType Copy) {} +struct PositiveValueUnusedConstructor { + PositiveValueUnusedConstructor(ExpensiveToCopyType Copy) {} + // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy' + // CHECK-FIXES: PositiveValueUnusedConstructor(const ExpensiveToCopyType& Copy) {} +}; + +struct PositiveValueCopiedConstructor { + PositiveValueCopiedConstructor(ExpensiveToCopyType Copy) : Field(Copy) {} + // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy' + // CHECK-FIXES: PositiveValueCopiedConstructor(const ExpensiveToCopyType& Copy) : Field(Copy) {} + ExpensiveToCopyType Field; }; template <typename T> |