summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp
diff options
context:
space:
mode:
authorFelix Berger <flx@google.com>2016-11-10 01:28:22 +0000
committerFelix Berger <flx@google.com>2016-11-10 01:28:22 +0000
commit85f9e8b3163c7147db22ccd6f8bf8bc659b3469f (patch)
tree9e2fe636fe5c60cb180d5dd9d5d1bd2d4c1996e0 /clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp
parent4e1b5a53c728ea48460c7ca8c8ac28e9bef92334 (diff)
downloadbcm5719-llvm-85f9e8b3163c7147db22ccd6f8bf8bc659b3469f.tar.gz
bcm5719-llvm-85f9e8b3163c7147db22ccd6f8bf8bc659b3469f.zip
[clang-tidy] Do not issue fix for functions that are referenced outside of callExpr
Summary: Suppress fixes for functions that are referenced within the compilation unit outside of a call expression as the signature change could break the code referencing the function. We still issue a warning in this case so that users can decide to manually change the function signature. Reviewers: alexfh, sbenza, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26203 llvm-svn: 286424
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp b/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp
index 2006942c181..3da15a359c8 100644
--- a/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ b/clang-tools-extra/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -253,3 +253,21 @@ void PositiveNonConstDeclaration(const ExpensiveToCopyType A) {
// CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'A'
// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A) {
}
+
+void PositiveOnlyMessageAsReferencedInCompilationUnit(ExpensiveToCopyType A) {
+ // CHECK-MESSAGES: [[@LINE-1]]:75: warning: the parameter 'A' is copied
+ // CHECK-FIXES: void PositiveOnlyMessageAsReferencedInCompilationUnit(ExpensiveToCopyType A) {
+}
+
+void ReferenceFunctionOutsideOfCallExpr() {
+ void (*ptr)(ExpensiveToCopyType) = &PositiveOnlyMessageAsReferencedInCompilationUnit;
+}
+
+void PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType A) {
+ // CHECK-MESSAGES: [[@LINE-1]]:66: warning: the parameter 'A' is copied
+ // CHECK-FIXES: void PositiveMessageAndFixAsFunctionIsCalled(const ExpensiveToCopyType& A) {
+}
+
+void ReferenceFunctionByCallingIt() {
+ PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType());
+}
OpenPOWER on IntegriCloud