10 #include "clang/AST/ASTContext.h"
11 #include "clang/ASTMatchers/ASTMatchFinder.h"
12 #include "clang/ASTMatchers/ASTMatchers.h"
19 return Node.hasExplicitTemplateArgs();
27 void ExplicitMakePairCheck::registerMatchers(
28 ast_matchers::MatchFinder *Finder) {
32 callExpr(unless(isInTemplateInstantiation()),
33 callee(expr(ignoringParenImpCasts(
34 declRefExpr(hasExplicitTemplateArgs(),
35 to(functionDecl(hasName(
"::std::make_pair"))))
41 void ExplicitMakePairCheck::check(
const MatchFinder::MatchResult &Result) {
42 const auto *Call = Result.Nodes.getNodeAs<CallExpr>(
"call");
43 const auto *
DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>(
"declref");
46 if (Call->getNumArgs() != 2)
49 const Expr *Arg0 = Call->getArg(0)->IgnoreParenImpCasts();
50 const Expr *Arg1 = Call->getArg(1)->IgnoreParenImpCasts();
55 if (Arg0->getType() != Call->getArg(0)->getType() ||
56 Arg1->getType() != Call->getArg(1)->getType()) {
57 diag(Call->getBeginLoc(),
"for C++11-compatibility, use pair directly")
58 << FixItHint::CreateReplacement(
62 diag(Call->getBeginLoc(),
63 "for C++11-compatibility, omit template arguments from make_pair")
64 << FixItHint::CreateRemoval(