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) {
31 if (!getLangOpts().CPlusPlus)
37 callExpr(unless(isInTemplateInstantiation()),
38 callee(expr(ignoringParenImpCasts(
39 declRefExpr(hasExplicitTemplateArgs(),
40 to(functionDecl(hasName(
"::std::make_pair"))))
46 void ExplicitMakePairCheck::check(
const MatchFinder::MatchResult &
Result) {
47 const auto *Call = Result.Nodes.getNodeAs<CallExpr>(
"call");
48 const auto *
DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>(
"declref");
51 if (Call->getNumArgs() != 2)
54 const Expr *Arg0 = Call->getArg(0)->IgnoreParenImpCasts();
55 const Expr *Arg1 = Call->getArg(1)->IgnoreParenImpCasts();
60 if (Arg0->getType() != Call->getArg(0)->getType() ||
61 Arg1->getType() != Call->getArg(1)->getType()) {
62 diag(Call->getBeginLoc(),
"for C++11-compatibility, use pair directly")
63 << FixItHint::CreateReplacement(
64 SourceRange(DeclRef->getBeginLoc(), DeclRef->getLAngleLoc()),
67 diag(Call->getBeginLoc(),
68 "for C++11-compatibility, omit template arguments from make_pair")
69 << FixItHint::CreateRemoval(
70 SourceRange(DeclRef->getLAngleLoc(), DeclRef->getRAngleLoc()));
AST_MATCHER(Expr, isMacroID)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
const DeclRefExpr * DeclRef