52 lines · cpp
1// RUN: %check_clang_tidy %s google-build-explicit-make-pair %t2 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>(1, 2);19// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, omit template arguments from make_pair20// 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>(i, i);28// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, omit template arguments from make_pair29// CHECK-FIXES: std::make_pair(i, i);30 31 std::make_pair<unsigned, int>(i, i);32// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair directly33// CHECK-FIXES: std::pair<unsigned, int>(i, i);34 35 std::make_pair<int, unsigned>(i, i);36// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair directly37// CHECK-FIXES: std::pair<int, unsigned>(i, i);38 39#define M std::make_pair<int, unsigned>(i, i);40M41// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: for C++11-compatibility, use pair directly42// Can't fix in macros.43// CHECK-FIXES: #define M std::make_pair<int, unsigned>(i, i);44// CHECK-FIXES-NEXT: M45 46 templ(i, i);47 templ(1U, 2U);48 49 std::make_pair(i, 1); // no-warning50 std::make_pair(t<int>, 1);51}52