10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
12#include "clang/ASTMatchers/ASTMatchers.h"
19 return Node.hasExplicitTemplateArgs();
23namespace tidy::google::build {
26 ast_matchers::MatchFinder *Finder) {
30 callExpr(unless(isInTemplateInstantiation()),
31 callee(expr(ignoringParenImpCasts(
32 declRefExpr(hasExplicitTemplateArgs(),
33 to(functionDecl(hasName(
"::std::make_pair"))))
40 const auto *Call = Result.Nodes.getNodeAs<CallExpr>(
"call");
41 const auto *
DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>(
"declref");
44 if (Call->getNumArgs() != 2)
47 const Expr *Arg0 = Call->getArg(0)->IgnoreParenImpCasts();
48 const Expr *Arg1 = Call->getArg(1)->IgnoreParenImpCasts();
53 if (Arg0->getType() != Call->getArg(0)->getType() ||
54 Arg1->getType() != Call->getArg(1)->getType()) {
55 diag(Call->getBeginLoc(),
"for C++11-compatibility, use pair directly")
56 << FixItHint::CreateReplacement(
60 diag(Call->getBeginLoc(),
61 "for C++11-compatibility, omit template arguments from make_pair")
62 << FixItHint::CreateRemoval(
::clang::DynTypedNode Node
const DeclRefExpr * DeclRef
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
AST_MATCHER(Decl, declHasNoReturnAttr)
matches a Decl if it has a "no return" attribute of any kind
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//