blob: 1d43a49e9ee6550d6dcd765f18953a5d6195559e [file] [log] [blame]
Benjamin Kramer082bf7f2014-07-14 14:24:30 +00001// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-swapped-arguments %t
2// REQUIRES: shell
3
4void F(int, double);
5
6int SomeFunction();
7
8template <typename T, typename U>
9void G(T a, U b) {
10 F(a, b); // no-warning
11 F(2.0, 4);
12// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
13// CHECK-FIXES: F(4, 2.0)
14}
15
16void foo() {
17 F(1.0, 3);
18// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
19// CHECK-FIXES: F(3, 1.0)
20
21#define M(x, y) x##y()
22
23 double b = 1.0;
24 F(b, M(Some, Function));
25// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
26// In macro, don't emit fixits.
27// CHECK-FIXES: F(b, M(Some, Function));
28
29#define N F(b, SomeFunction())
30
31 N;
32// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
33// In macro, don't emit fixits.
34// CHECK-FIXES: #define N F(b, SomeFunction())
35
36 G(b, 3);
37 G(3, 1.0);
38 G(0, 0);
39
40 F(1.0, 1.0); // no-warning
41 F(3, 1.0); // no-warning
42 F(true, false); // no-warning
43 F(0, 'c'); // no-warning
44}