[clang-tools-extra] r350526 - [clang-tidy] Use the public hasInit matcher, rather than defining our own, NFC

Hyrum Wright via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 7 06:36:47 PST 2019


Author: hwright
Date: Mon Jan  7 06:36:47 2019
New Revision: 350526

URL: http://llvm.org/viewvc/llvm-project?rev=350526&view=rev
Log:
[clang-tidy] Use the public hasInit matcher, rather than defining our own, NFC

Modified:
    clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp?rev=350526&r1=350525&r2=350526&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp Mon Jan  7 06:36:47 2019
@@ -104,20 +104,6 @@ llvm::StringRef getFactoryForScale(Durat
   llvm_unreachable("unknown scaling factor");
 }
 
-/// Matches the n'th item of an initializer list expression.
-///
-/// Example matches y.
-///     (matcher = initListExpr(hasInit(0, expr())))
-/// \code
-///   int x{y}.
-/// \endcode
-AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,
-               ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
-  return N < Node.getNumInits() &&
-          InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,
-                               Builder);
-}
-
 /// Returns `true` if `Node` is a value which evaluates to a literal `0`.
 bool IsLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) {
   auto ZeroMatcher =
@@ -132,13 +118,13 @@ bool IsLiteralZero(const MatchFinder::Ma
   // Now check to see if we're using a functional cast with a scalar
   // initializer expression, e.g. `int{0}`.
   if (selectFirst<const clang::Expr>(
-          "val",
-          match(cxxFunctionalCastExpr(
-                    hasDestinationType(
-                        anyOf(isInteger(), realFloatingPointType())),
-                    hasSourceExpression(initListExpr(hasInit(0, ZeroMatcher))))
-                    .bind("val"),
-                Node, *Result.Context)) != nullptr)
+          "val", match(cxxFunctionalCastExpr(
+                           hasDestinationType(
+                               anyOf(isInteger(), realFloatingPointType())),
+                           hasSourceExpression(initListExpr(
+                               hasInit(0, ignoringParenImpCasts(ZeroMatcher)))))
+                           .bind("val"),
+                       Node, *Result.Context)) != nullptr)
     return true;
 
   return false;




More information about the cfe-commits mailing list