blob: 257fd0621c7710f70ab185cba5ac27128df77a9d [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);
19}
20
21void test(int i) {
22 std::make_pair<int, int>(i, i);
23// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, omit template arguments from make_pair
24// CHECK-FIXES: std::make_pair(i, i)
25
26 std::make_pair<unsigned, int>(i, i);
27// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair directly
28// CHECK-FIXES: std::pair<unsigned, int>(i, i)
29
30 std::make_pair<int, unsigned>(i, i);
31// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair directly
32// CHECK-FIXES: std::pair<int, unsigned>(i, i)
33
34#define M std::make_pair<int, unsigned>(i, i);
35M
36// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: for C++11-compatibility, use pair directly
37// Can't fix in macros.
38// CHECK-FIXES: #define M std::make_pair<int, unsigned>(i, i);
39// CHECK-FIXES-NEXT: M
40
41 templ(i, i);
42
43 std::make_pair(i, 1); // no-warning
44}