blob: 4d7b209e6f508372f854049441b6b75f9ad2be9a [file] [log] [blame]
Benjamin Kramer47c4d102014-07-15 09:50:32 +00001// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s google-build-explicit-make-pair %t
2// REQUIRES: shell
3
4namespace std {
5template <class T1, class T2>
6struct pair {
7 pair(T1 x, T2 y) {}
8};
9
10template <class T1, class T2>
11pair<T1, T2> make_pair(T1 x, T2 y) {
12 return pair<T1, T2>(x, y);
13}
14}
15
16template <typename T>
17void templ(T a, T b) {
18 std::make_pair<T, unsigned>(a, b);
Benjamin Kramer2b584f32014-07-15 13:11:49 +000019 std::make_pair<int, int>(1, 2);
20// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, omit template arguments from make_pair
21// CHECK-FIXES: std::make_pair(1, 2)
Benjamin Kramer47c4d102014-07-15 09:50:32 +000022}
23
24void test(int i) {
25 std::make_pair<int, int>(i, i);
26// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, omit template arguments from make_pair
27// CHECK-FIXES: std::make_pair(i, i)
28
29 std::make_pair<unsigned, int>(i, i);
30// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair directly
31// CHECK-FIXES: std::pair<unsigned, int>(i, i)
32
33 std::make_pair<int, unsigned>(i, i);
34// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair directly
35// CHECK-FIXES: std::pair<int, unsigned>(i, i)
36
37#define M std::make_pair<int, unsigned>(i, i);
38M
39// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: for C++11-compatibility, use pair directly
40// Can't fix in macros.
41// CHECK-FIXES: #define M std::make_pair<int, unsigned>(i, i);
42// CHECK-FIXES-NEXT: M
43
44 templ(i, i);
Benjamin Kramer2b584f32014-07-15 13:11:49 +000045 templ(1U, 2U);
Benjamin Kramer47c4d102014-07-15 09:50:32 +000046
47 std::make_pair(i, 1); // no-warning
48}