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

Alexander Kornienko alexfh at google.com
Tue Jul 15 06:31:02 PDT 2014


================
Comment at: clang-tidy/google/NamedParameterCheck.cpp:31
@@ +30,3 @@
+  // Ignore implicitly generated members.
+  if (Function->isDefaulted() && !Function->isExplicitlyDefaulted())
+    return;
----------------
Why don't you check for isImplicit()?

================
Comment at: clang-tidy/google/NamedParameterCheck.cpp:36
@@ +35,3 @@
+  // TODO: We could check that all redeclarations use the same name for
+  //       arguments in the same position.
+  for (const ParmVarDecl *Parm : Function->params()) {
----------------
Alternatively this could be done in the swapped arguments check. Both places seem good for this.

================
Comment at: clang-tidy/google/NamedParameterCheck.cpp:50
@@ +49,3 @@
+    const char *Begin = SM.getCharacterData(Parm->getLocStart());
+    const char *End = SM.getCharacterData(Parm->getLocation());
+    StringRef Data(Begin, End - Begin);
----------------
I'm curious where does Parm->getLocation() point in case where there is a parameter name (to the identifier?) and where there is not?

================
Comment at: clang-tidy/google/NamedParameterCheck.h:19
@@ +18,3 @@
+
+/// \brief Find functions with unnamed arguments.
+/// Corresponding cpplint.py check name: 'readability/function'.
----------------
nit: Do we need an empty line to separate the \brief from the rest of the class comment?

================
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
----------------
Please add tests with multiple instantiations of the same template. I suspect, currently the check will suggest multiple replacements.

http://reviews.llvm.org/D4518






More information about the cfe-commits mailing list