summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-07-22 17:30:35 +0000
committerDaniel Jasper <djasper@google.com>2015-07-22 17:30:35 +0000
commit9b46e9c5de19f91c4b6b8b1d3405875c48190aac (patch)
treeb2e9e12f77e4ad64909eb0c78562c4a930095a8a /clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp
parent2c674d347e067b865390db50cafd035ad2c5f4c7 (diff)
downloadbcm5719-llvm-9b46e9c5de19f91c4b6b8b1d3405875c48190aac.tar.gz
bcm5719-llvm-9b46e9c5de19f91c4b6b8b1d3405875c48190aac.zip
misc-unused-parameters: Fix handling of parameters in template functions.
The parameters of the function templates were being marked as incorrectly be marked as unused. Added a test for this and changed the check to use the same isReferenced() || !getDeclName() logic as Sema::DiagnoseUnusedParameters. Patch Scott Wallace, thank you! llvm-svn: 242912
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp
index 3b54cc5a3bf..fc8a4eecdf8 100644
--- a/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp
@@ -88,3 +88,14 @@ void someMoreCallSites() {
}
} // end namespace
+
+template <typename T> void someFunctionTemplate(T b, T e) { (void)b; (void)e; }
+
+template <typename T> void someFunctionTemplateOneUnusedParam(T b, T e) { (void)e; }
+// CHECK-MESSAGES: :[[@LINE-1]]:65: warning
+// CHECK-FIXES: {{^}}template <typename T> void someFunctionTemplateOneUnusedParam(T /*b*/, T e) { (void)e; }
+
+template <typename T> void someFunctionTemplateAllUnusedParams(T b, T e) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:66: warning
+// CHECK-MESSAGES: :[[@LINE-2]]:71: warning
+// CHECK-FIXES: {{^}}template <typename T> void someFunctionTemplateAllUnusedParams(T /*b*/, T /*e*/) {}
OpenPOWER on IntegriCloud