blob: 128bc750ef78bebcbfde9a6102abd33cc4060cb1 [file] [log] [blame]
Manuel Klimekb91bee02015-10-22 11:31:44 +00001// RUN: %check_clang_tidy %s misc-swapped-arguments %t
Benjamin Kramer082bf7f2014-07-14 14:24:30 +00002
3void F(int, double);
4
5int SomeFunction();
6
7template <typename T, typename U>
8void G(T a, U b) {
9 F(a, b); // no-warning
10 F(2.0, 4);
11// 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.
12// CHECK-FIXES: F(4, 2.0)
13}
14
15void foo() {
16 F(1.0, 3);
17// 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.
18// CHECK-FIXES: F(3, 1.0)
19
20#define M(x, y) x##y()
21
22 double b = 1.0;
23 F(b, M(Some, Function));
24// 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.
25// In macro, don't emit fixits.
26// CHECK-FIXES: F(b, M(Some, Function));
27
28#define N F(b, SomeFunction())
29
30 N;
31// 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.
32// In macro, don't emit fixits.
33// CHECK-FIXES: #define N F(b, SomeFunction())
34
35 G(b, 3);
36 G(3, 1.0);
37 G(0, 0);
38
39 F(1.0, 1.0); // no-warning
40 F(3, 1.0); // no-warning
41 F(true, false); // no-warning
42 F(0, 'c'); // no-warning
43}