[clang-tools-extra] r214874 - [clang-tidy] Simplify ast matcher.

Benjamin Kramer benny.kra at googlemail.com
Tue Aug 5 08:33:46 PDT 2014


Author: d0k
Date: Tue Aug  5 10:33:46 2014
New Revision: 214874

URL: http://llvm.org/viewvc/llvm-project?rev=214874&view=rev
Log:
[clang-tidy] Simplify ast matcher.

Turns out there is a better way to do this. No functionality change.

Modified:
    clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp?rev=214874&r1=214873&r2=214874&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitMakePairCheck.cpp Tue Aug  5 10:33:46 2014
@@ -20,15 +20,6 @@ namespace ast_matchers {
 AST_MATCHER(DeclRefExpr, hasExplicitTemplateArgs) {
   return Node.hasExplicitTemplateArgs();
 }
-
-// FIXME: This should just be callee(ignoringImpCasts()) but it's not overloaded
-// for Expr.
-AST_MATCHER_P(CallExpr, calleeIgnoringParenImpCasts, internal::Matcher<Stmt>,
-              InnerMatcher) {
-  const Expr *ExprNode = Node.getCallee();
-  return (ExprNode != nullptr &&
-          InnerMatcher.matches(*ExprNode->IgnoreParenImpCasts(), Finder, Builder));
-}
 } // namespace ast_matchers
 
 namespace tidy {
@@ -42,10 +33,10 @@ ExplicitMakePairCheck::registerMatchers(
       callExpr(unless(hasAncestor(decl(anyOf(
                    recordDecl(ast_matchers::isTemplateInstantiation()),
                    functionDecl(ast_matchers::isTemplateInstantiation()))))),
-               calleeIgnoringParenImpCasts(
+               callee(expr(ignoringParenImpCasts(
                    declRefExpr(hasExplicitTemplateArgs(),
                                to(functionDecl(hasName("::std::make_pair"))))
-                       .bind("declref"))).bind("call"),
+                       .bind("declref"))))).bind("call"),
       this);
 }
 





More information about the cfe-commits mailing list