2015-10-22 19:31:44 +08:00
|
|
|
// RUN: %check_clang_tidy %s readability-named-parameter %t
|
2014-07-16 00:47:09 +08:00
|
|
|
|
|
|
|
void Method(char *) { /* */ }
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: all parameters should be named in a function
|
|
|
|
// CHECK-FIXES: void Method(char * /*unused*/) { /* */ }
|
2014-08-04 17:33:58 +08:00
|
|
|
void Method2(char *) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function
|
2014-08-04 17:33:58 +08:00
|
|
|
// CHECK-FIXES: void Method2(char * /*unused*/) {}
|
|
|
|
void Method3(char *, void *) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function
|
2014-08-04 17:33:58 +08:00
|
|
|
// CHECK-FIXES: void Method3(char * /*unused*/, void * /*unused*/) {}
|
|
|
|
void Method4(char *, int /*unused*/) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function
|
2014-08-04 17:33:58 +08:00
|
|
|
// CHECK-FIXES: void Method4(char * /*unused*/, int /*unused*/) {}
|
|
|
|
void operator delete[](void *) throw() {}
|
2014-07-16 00:47:09 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: all parameters should be named in a function
|
2014-08-04 17:33:58 +08:00
|
|
|
// CHECK-FIXES: void operator delete[](void * /*unused*/) throw() {}
|
|
|
|
int Method5(int) { return 0; }
|
2014-07-16 00:47:09 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: all parameters should be named in a function
|
2014-08-04 17:33:58 +08:00
|
|
|
// CHECK-FIXES: int Method5(int /*unused*/) { return 0; }
|
2014-07-16 00:47:09 +08:00
|
|
|
void Method6(void (*)(void *)) {}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: all parameters should be named in a function
|
|
|
|
// CHECK-FIXES: void Method6(void (* /*unused*/)(void *)) {}
|
2014-08-04 17:33:58 +08:00
|
|
|
template <typename T> void Method7(T) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: all parameters should be named in a function
|
2014-08-04 17:33:58 +08:00
|
|
|
// CHECK-FIXES: template <typename T> void Method7(T /*unused*/) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
|
|
|
|
// Don't warn in macros.
|
2014-08-04 17:33:58 +08:00
|
|
|
#define M void MethodM(int) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
M
|
|
|
|
|
2014-08-04 17:33:58 +08:00
|
|
|
void operator delete(void *x) throw() {}
|
2014-07-16 00:47:09 +08:00
|
|
|
void Method7(char * /*x*/) {}
|
2014-08-04 17:33:58 +08:00
|
|
|
void Method8(char *x) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
typedef void (*TypeM)(int x);
|
|
|
|
void operator delete[](void *x) throw();
|
|
|
|
void operator delete[](void * /*x*/) throw();
|
|
|
|
|
|
|
|
struct X {
|
2014-08-04 17:33:58 +08:00
|
|
|
X operator++(int) {}
|
2014-09-01 17:11:48 +08:00
|
|
|
X operator--(int) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
|
2014-08-29 16:58:35 +08:00
|
|
|
X(X&) = delete;
|
|
|
|
X &operator=(X&) = default;
|
|
|
|
|
2014-07-16 00:47:09 +08:00
|
|
|
const int &i;
|
|
|
|
};
|
|
|
|
|
|
|
|
void (*Func1)(void *);
|
|
|
|
void Func2(void (*func)(void *)) {}
|
2014-08-04 17:33:58 +08:00
|
|
|
template <void Func(void *)> void Func3() {}
|
2014-07-16 00:47:09 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct Y {
|
2014-08-04 17:33:58 +08:00
|
|
|
void foo(T) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: all parameters should be named in a function
|
2014-08-04 17:33:58 +08:00
|
|
|
// CHECK-FIXES: void foo(T /*unused*/) {}
|
2014-07-16 00:47:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Y<int> y;
|
|
|
|
Y<float> z;
|
|
|
|
|
|
|
|
struct Base {
|
|
|
|
virtual void foo(bool notThisOne);
|
|
|
|
virtual void foo(int argname);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Derived : public Base {
|
|
|
|
void foo(int);
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: all parameters should be named in a function
|
|
|
|
// CHECK-FIXES: void foo(int /*argname*/);
|
|
|
|
};
|
2014-08-04 17:33:58 +08:00
|
|
|
|
|
|
|
void FDef(int);
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: all parameters should be named in a function
|
|
|
|
// CHECK-FIXES: void FDef(int /*n*/);
|
2014-08-04 17:42:18 +08:00
|
|
|
void FDef(int n) {}
|
|
|
|
|
|
|
|
void FDef2(int, int);
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: all parameters should be named in a function
|
|
|
|
// CHECK-FIXES: void FDef2(int /*n*/, int /*unused*/);
|
|
|
|
void FDef2(int n, int) {}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: all parameters should be named in a function
|
|
|
|
// CHECK-FIXES: void FDef2(int n, int /*unused*/) {}
|
2014-08-04 17:33:58 +08:00
|
|
|
|
|
|
|
void FNoDef(int);
|
2014-09-01 17:11:48 +08:00
|
|
|
|
|
|
|
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) {}
|
2014-09-25 16:16:24 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2014-11-05 19:08:39 +08:00
|
|
|
|
|
|
|
namespace std {
|
|
|
|
typedef decltype(nullptr) nullptr_t;
|
|
|
|
}
|
|
|
|
|
|
|
|
void f(std::nullptr_t) {}
|
2015-11-06 08:19:21 +08:00
|
|
|
|
|
|
|
typedef void (F)(int);
|
|
|
|
F f;
|
|
|
|
void f(int x) {}
|