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

source code of clang-tools-extra/test/clang-tidy/checkers/google/build-explicit-make-pair.cpp