[clang-tools-extra] r216868 - [clang-tidy] Don't suggest naming the dummy argument of a post-inc operator overload.

Benjamin Kramer benny.kra at googlemail.com
Mon Sep 1 02:11:49 PDT 2014


Author: d0k
Date: Mon Sep  1 04:11:48 2014
New Revision: 216868

URL: http://llvm.org/viewvc/llvm-project?rev=216868&view=rev
Log:
[clang-tidy] Don't suggest naming the dummy argument of a post-inc operator overload.

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=216868&r1=216867&r2=216868&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/NamedParameterCheck.cpp Mon Sep  1 04:11:48 2014
@@ -55,6 +55,12 @@ void NamedParameterCheck::check(const Ma
     if (!Parm->getName().empty())
       continue;
 
+    // Don't warn on the dummy argument on post-inc and post-dec operators.
+    if ((Function->getOverloadedOperator() == OO_PlusPlus ||
+         Function->getOverloadedOperator() == OO_MinusMinus) &&
+        Parm->getType()->isSpecificBuiltinType(BuiltinType::Int))
+      continue;
+
     // Sanity check the source locations.
     if (!Parm->getLocation().isValid() || Parm->getLocation().isMacroID() ||
         !SM.isWrittenInSameFile(Parm->getLocStart(), Parm->getLocation()))

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=216868&r1=216867&r2=216868&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 Mon Sep  1 04:11:48 2014
@@ -39,9 +39,7 @@ void operator delete[](void * /*x*/) thr
 
 struct X {
   X operator++(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: all parameters should be named in a function
-// CHECK-FIXES: X operator++(int /*unused*/) {}
-  X operator--(int /*unused*/) {}
+  X operator--(int) {}
 
   X(X&) = delete;
   X &operator=(X&) = default;
@@ -87,3 +85,21 @@ void FDef2(int n, int) {}
 // CHECK-FIXES: void FDef2(int n, int /*unused*/) {}
 
 void FNoDef(int);
+
+class Z {};
+
+Z &operator++(Z&) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function
+// CHECK-FIXES: Z &operator++(Z& /*unused*/) {}
+
+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) {}
+
+Z &operator--(Z&) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function
+// CHECK-FIXES: Z &operator--(Z& /*unused*/) {}
+
+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) {}





More information about the cfe-commits mailing list