2017-11-24 01:02:48 +08:00
|
|
|
// RUN: %check_clang_tidy %s bugprone-argument-comment %t
|
2014-03-18 12:46:45 +08:00
|
|
|
|
|
|
|
// FIXME: clang-tidy should provide a -verify mode to make writing these checks
|
|
|
|
// easier and more accurate.
|
|
|
|
|
|
|
|
void ffff(int xxxx, int yyyy);
|
|
|
|
|
2014-07-30 22:31:36 +08:00
|
|
|
void f(int x, int y);
|
2014-03-18 12:46:45 +08:00
|
|
|
void g() {
|
2018-09-18 18:15:15 +08:00
|
|
|
// CHECK-NOTES: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
|
|
|
|
// CHECK-NOTES: [[@LINE-3]]:12: note: 'x' declared here
|
|
|
|
// CHECK-NOTES: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
|
|
|
|
// CHECK-NOTES: [[@LINE-5]]:19: note: 'y' declared here
|
2014-03-18 12:46:45 +08:00
|
|
|
f(/*y=*/0, /*z=*/0);
|
2016-06-08 23:27:46 +08:00
|
|
|
// CHECK-FIXES: {{^}} f(/*y=*/0, /*z=*/0);
|
2017-02-01 23:28:25 +08:00
|
|
|
|
2017-11-24 01:02:48 +08:00
|
|
|
f(/*x=*/1, /*y=*/1);
|
|
|
|
|
2017-02-01 23:28:25 +08:00
|
|
|
ffff(0 /*aaaa=*/, /*bbbb*/ 0); // Unsupported formats.
|
2014-03-18 12:46:45 +08:00
|
|
|
}
|
|
|
|
|
2017-11-24 01:02:48 +08:00
|
|
|
struct C {
|
|
|
|
C(int x, int y);
|
|
|
|
};
|
|
|
|
C c(/*x=*/0, /*y=*/0);
|
|
|
|
|
2014-07-30 22:31:36 +08:00
|
|
|
struct Closure {};
|
|
|
|
|
|
|
|
template <typename T1, typename T2>
|
|
|
|
Closure *NewCallback(void (*f)(T1, T2), T1 arg1, T2 arg2) { return nullptr; }
|
|
|
|
|
|
|
|
template <typename T1, typename T2>
|
|
|
|
Closure *NewPermanentCallback(void (*f)(T1, T2), T1 arg1, T2 arg2) { return nullptr; }
|
|
|
|
|
|
|
|
void h() {
|
|
|
|
(void)NewCallback(&ffff, /*xxxx=*/11, /*yyyy=*/22);
|
|
|
|
(void)NewPermanentCallback(&ffff, /*xxxx=*/11, /*yyyy=*/22);
|
|
|
|
}
|
2014-09-03 22:56:30 +08:00
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
void variadic(Args&&... args);
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
void variadic2(int zzz, Args&&... args);
|
|
|
|
|
|
|
|
void templates() {
|
|
|
|
variadic(/*xxx=*/0, /*yyy=*/1);
|
2016-08-04 22:54:54 +08:00
|
|
|
variadic2(/*zzU=*/0, /*xxx=*/1, /*yyy=*/2);
|
2018-09-18 18:15:15 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-1]]:13: warning: argument name 'zzU' in comment does not match parameter name 'zzz'
|
2018-10-05 00:39:41 +08:00
|
|
|
// CHECK-NOTES: :[[@LINE-6]]:20: note: 'zzz' declared here
|
2016-06-08 23:27:46 +08:00
|
|
|
// CHECK-FIXES: variadic2(/*zzz=*/0, /*xxx=*/1, /*yyy=*/2);
|
2014-09-03 22:56:30 +08:00
|
|
|
}
|
2016-06-08 23:27:46 +08:00
|
|
|
|
|
|
|
#define FALSE 0
|
|
|
|
void qqq(bool aaa);
|
2017-11-24 01:02:48 +08:00
|
|
|
void f2() { qqq(/*bbb=*/FALSE); }
|
2018-09-18 18:15:15 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-1]]:17: warning: argument name 'bbb' in comment does not match parameter name 'aaa'
|
|
|
|
// CHECK-NOTES: [[@LINE-3]]:15: note: 'aaa' declared here
|
2017-11-24 01:02:48 +08:00
|
|
|
// CHECK-FIXES: void f2() { qqq(/*bbb=*/FALSE); }
|
2016-08-04 22:54:54 +08:00
|
|
|
|
2017-11-24 01:02:48 +08:00
|
|
|
void f3(bool _with_underscores_);
|
2016-08-04 22:54:54 +08:00
|
|
|
void ignores_underscores() {
|
2017-11-24 01:02:48 +08:00
|
|
|
f3(/*With_Underscores=*/false);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ThisEditDistanceAboveThreshold {
|
|
|
|
void f4(int xxx);
|
|
|
|
void g() { f4(/*xyz=*/0); }
|
2018-09-18 18:15:15 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'xyz' in comment does not match parameter name 'xxx'
|
|
|
|
// CHECK-NOTES: [[@LINE-3]]:13: note: 'xxx' declared here
|
2017-11-24 01:02:48 +08:00
|
|
|
// CHECK-FIXES: void g() { f4(/*xyz=*/0); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace OtherEditDistanceAboveThreshold {
|
|
|
|
void f5(int xxx, int yyy);
|
|
|
|
void g() { f5(/*Zxx=*/0, 0); }
|
2018-09-18 18:15:15 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
|
2018-10-05 00:39:41 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-3]]:13: note: 'xxx' declared here
|
2017-11-24 01:02:48 +08:00
|
|
|
// CHECK-FIXES: void g() { f5(/*xxx=*/0, 0); }
|
|
|
|
struct C2 {
|
|
|
|
C2(int xxx, int yyy);
|
|
|
|
};
|
|
|
|
C2 c2(/*Zxx=*/0, 0);
|
2018-09-18 18:15:15 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-1]]:7: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
|
2018-10-05 00:39:41 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-4]]:10: note: 'xxx' declared here
|
2017-11-24 01:02:48 +08:00
|
|
|
// CHECK-FIXES: C2 c2(/*xxx=*/0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace OtherEditDistanceBelowThreshold {
|
|
|
|
void f6(int xxx, int yyy);
|
|
|
|
void g() { f6(/*xxy=*/0, 0); }
|
2018-09-18 18:15:15 +08:00
|
|
|
// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'xxy' in comment does not match parameter name 'xxx'
|
|
|
|
// CHECK-NOTES: [[@LINE-3]]:13: note: 'xxx' declared here
|
2017-11-24 01:02:48 +08:00
|
|
|
// CHECK-FIXES: void g() { f6(/*xxy=*/0, 0); }
|
2016-08-04 22:54:54 +08:00
|
|
|
}
|