[clang-tools-extra] r218443 - Clang-tidy google-readability-function check: don't warn on gmock
Alexander Kornienko
alexfh at google.com
Thu Sep 25 01:16:24 PDT 2014
Author: alexfh
Date: Thu Sep 25 03:16:24 2014
New Revision: 218443
URL: http://llvm.org/viewvc/llvm-project?rev=218443&view=rev
Log:
Clang-tidy google-readability-function check: don't warn on gmock
testing::Unused parameters.
Reviewers: bkramer, klimek
Reviewed By: klimek
Subscribers: curdeius, cfe-commits
Differential Revision: http://reviews.llvm.org/D5479
Modified:
clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-function.cpp
Modified: clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp?rev=218443&r1=218442&r2=218443&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp Thu Sep 25 03:16:24 2014
@@ -60,6 +60,11 @@ void NamedParameterCheck::check(const Ma
!SM.isWrittenInSameFile(Parm->getLocStart(), Parm->getLocation()))
continue;
+ // Skip gmock testing::Unused parameters.
+ if (auto Typedef = Parm->getType()->getAs<clang::TypedefType>())
+ if (Typedef->getDecl()->getQualifiedNameAsString() == "testing::Unused")
+ continue;
+
// Look for comments. We explicitly want to allow idioms like
// void foo(int /*unused*/)
const char *Begin = SM.getCharacterData(Parm->getLocStart());
Modified: clang-tools-extra/trunk/test/clang-tidy/google-readability-function.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-function.cpp?rev=218443&r1=218442&r2=218443&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-function.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-function.cpp Thu Sep 25 03:16:24 2014
@@ -103,3 +103,22 @@ Z &operator--(Z&) {}
Z &operator--(Z&, int) {}
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function
// CHECK-FIXES: Z &operator--(Z& /*unused*/, int) {}
+
+namespace testing {
+namespace internal {
+class IgnoredValue {
+ public:
+ template <typename T>
+ IgnoredValue(const T& /* ignored */) {}
+};
+}
+typedef internal::IgnoredValue Unused;
+}
+
+using ::testing::Unused;
+
+void MockFunction(Unused, int q, Unused) {
+ ++q;
+ ++q;
+ ++q;
+}
More information about the cfe-commits
mailing list