| 1 |
// RUN: %check_clang_tidy %s readability-named-parameter %t |
| 2 |
|
| 3 |
void Method(char *) { /* */ } |
| 4 |
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: all parameters should be named in a function |
| 5 |
// CHECK-FIXES: void Method(char * /*unused*/) { /* */ } |
| 6 |
void Method2(char *) {} |
| 7 |
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function |
| 8 |
// CHECK-FIXES: void Method2(char * /*unused*/) {} |
| 9 |
void Method3(char *, void *) {} |
| 10 |
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function |
| 11 |
// CHECK-FIXES: void Method3(char * /*unused*/, void * /*unused*/) {} |
| 12 |
void Method4(char *, int /*unused*/) {} |
| 13 |
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: all parameters should be named in a function |
| 14 |
// CHECK-FIXES: void Method4(char * /*unused*/, int /*unused*/) {} |
| 15 |
void operator delete[](void *) throw() {} |
| 16 |
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: all parameters should be named in a function |
| 17 |
// CHECK-FIXES: void operator delete[](void * /*unused*/) throw() {} |
| 18 |
int Method5(int) { return 0; } |
| 19 |
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: all parameters should be named in a function |
| 20 |
// CHECK-FIXES: int Method5(int /*unused*/) { return 0; } |
| 21 |
void Method6(void (*)(void *)) {} |
| 22 |
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: all parameters should be named in a function |
| 23 |
// CHECK-FIXES: void Method6(void (* /*unused*/)(void *)) {} |
| 24 |
template <typename T> void Method7(T) {} |
| 25 |
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: all parameters should be named in a function |
| 26 |
// CHECK-FIXES: template <typename T> void Method7(T /*unused*/) {} |
| 27 |
|
| 28 |
// Don't warn in macros. |
| 29 |
#define M void MethodM(int) {} |
| 30 |
M |
| 31 |
|
| 32 |
void operator delete(void *x) throw() {} |
| 33 |
void Method7(char * /*x*/) {} |
| 34 |
void Method8(char *x) {} |
| 35 |
typedef void (*TypeM)(int x); |
| 36 |
void operator delete[](void *x) throw(); |
| 37 |
void operator delete[](void * /*x*/) throw(); |
| 38 |
|
| 39 |
struct X { |
| 40 |
X operator++(int) {} |
| 41 |
X operator--(int) {} |
| 42 |
|
| 43 |
X(X&) = delete; |
| 44 |
X &operator=(X&) = default; |
| 45 |
|
| 46 |
const int &i; |
| 47 |
}; |
| 48 |
|
| 49 |
void (*Func1)(void *); |
| 50 |
void Func2(void (*func)(void *)) {} |
| 51 |
template <void Func(void *)> void Func3() {} |
| 52 |
|
| 53 |
template <typename T> |
| 54 |
struct Y { |
| 55 |
void foo(T) {} |
| 56 |
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: all parameters should be named in a function |
| 57 |
// CHECK-FIXES: void foo(T /*unused*/) {} |
| 58 |
}; |
| 59 |
|
| 60 |
Y<int> y; |
| 61 |
Y<float> z; |
| 62 |
|
| 63 |
struct Base { |
| 64 |
virtual void foo(bool notThisOne); |
| 65 |
virtual void foo(int argname); |
| 66 |
}; |
| 67 |
|
| 68 |
struct Derived : public Base { |
| 69 |
void foo(int); |
| 70 |
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: all parameters should be named in a function |
| 71 |
// CHECK-FIXES: void foo(int /*argname*/); |
| 72 |
}; |
| 73 |
|
| 74 |
void FDef(int); |
| 75 |
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: all parameters should be named in a function |
| 76 |
// CHECK-FIXES: void FDef(int /*n*/); |
| 77 |
void FDef(int n) {} |
| 78 |
|
| 79 |
void FDef2(int, int); |
| 80 |
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: all parameters should be named in a function |
| 81 |
// CHECK-FIXES: void FDef2(int /*n*/, int /*unused*/); |
| 82 |
void FDef2(int n, int) {} |
| 83 |
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: all parameters should be named in a function |
| 84 |
// CHECK-FIXES: void FDef2(int n, int /*unused*/) {} |
| 85 |
|
| 86 |
void FNoDef(int); |
| 87 |
|
| 88 |
class Z {}; |
| 89 |
|
| 90 |
Z &operator++(Z&) {} |
| 91 |
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function |
| 92 |
// CHECK-FIXES: Z &operator++(Z& /*unused*/) {} |
| 93 |
|
| 94 |
Z &operator++(Z&, int) {} |
| 95 |
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function |
| 96 |
// CHECK-FIXES: Z &operator++(Z& /*unused*/, int) {} |
| 97 |
|
| 98 |
Z &operator--(Z&) {} |
| 99 |
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function |
| 100 |
// CHECK-FIXES: Z &operator--(Z& /*unused*/) {} |
| 101 |
|
| 102 |
Z &operator--(Z&, int) {} |
| 103 |
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: all parameters should be named in a function |
| 104 |
// CHECK-FIXES: Z &operator--(Z& /*unused*/, int) {} |
| 105 |
|
| 106 |
namespace testing { |
| 107 |
namespace internal { |
| 108 |
class IgnoredValue { |
| 109 |
public: |
| 110 |
template <typename T> |
| 111 |
IgnoredValue(const T& /* ignored */) {} |
| 112 |
}; |
| 113 |
} |
| 114 |
typedef internal::IgnoredValue Unused; |
| 115 |
} |
| 116 |
|
| 117 |
using ::testing::Unused; |
| 118 |
|
| 119 |
void MockFunction(Unused, int q, Unused) { |
| 120 |
++q; |
| 121 |
++q; |
| 122 |
++q; |
| 123 |
} |
| 124 |
|
| 125 |
namespace std { |
| 126 |
typedef decltype(nullptr) nullptr_t; |
| 127 |
} |
| 128 |
|
| 129 |
void f(std::nullptr_t) {} |
| 130 |
|
| 131 |
typedef void (F)(int); |
| 132 |
F f; |
| 133 |
void f(int x) {} |
| 134 |
|
| 135 |
namespace issue_63056 |
| 136 |
{ |
| 137 |
struct S { |
| 138 |
S(const S&); |
| 139 |
S(S&&); |
| 140 |
|
| 141 |
S& operator=(const S&); |
| 142 |
S& operator=(S&&); |
| 143 |
}; |
| 144 |
|
| 145 |
S::S(const S&) = default; |
| 146 |
S::S(S&&) = default; |
| 147 |
|
| 148 |
S& S::operator=(const S&) = default; |
| 149 |
S& S::operator=(S&&) = default; |
| 150 |
} // namespace issue_63056 |