[PATCH] [clang-tidy] Add a checker that flags unnamed parameters.

Alexander Kornienko alexfh at google.com
Tue Jul 15 08:24:51 PDT 2014


================
Comment at: test/clang-tidy/google-readability-function.cpp:69
@@ +68,3 @@
+struct Derived : public Base {
+  void foo(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: all parameters should be named in a function
----------------
What does the check do in this case? 

  struct Base1 { virtual void f(int i) {} };
  struct Base2 { virtual void f(bool b) {} };
  template <typename T, typename Y>
  struct Derived : public T {
    void f(Y) {}
  };
  int main() {
    Derived<Base1, int>();
    Derived<Base2, bool>();
  }


================
Comment at: test/clang-tidy/google-readability-function.cpp:1
@@ +1,2 @@
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-readability-function %t
+// REQUIRES: shell
----------------
Benjamin Kramer wrote:
> Alexander Kornienko wrote:
> > Please add tests with multiple instantiations of the same template. I suspect, currently the check will suggest multiple replacements.
> I checked that and it doesn't (do warnings get deduplicated somewhere)? I'll add another test.
Warnings get deduplicated by location and message text, and in your test case deduplication worked correctly. But it's not a good idea to rely on the deduplication in general.

http://reviews.llvm.org/D4518






More information about the cfe-commits mailing list