diff options
author | Hyrum Wright <hwright@google.com> | 2019-01-07 14:36:47 +0000 |
---|---|---|
committer | Hyrum Wright <hwright@google.com> | 2019-01-07 14:36:47 +0000 |
commit | 1bec67f605c067e70a6df52479e899d1cbe6d47a (patch) | |
tree | 57e76587246843f385819895d349ec5c0b86d652 /clang-tools-extra | |
parent | [AST][NFC] Pack DependentScopeDeclRefExpr and CXXUnresolvedConstructExpr (diff) | |
download | llvm-project-1bec67f605c067e70a6df52479e899d1cbe6d47a.tar.gz llvm-project-1bec67f605c067e70a6df52479e899d1cbe6d47a.tar.bz2 llvm-project-1bec67f605c067e70a6df52479e899d1cbe6d47a.zip |
[clang-tidy] Use the public hasInit matcher, rather than defining our own, NFC
llvm-svn: 350526
Diffstat (limited to 'clang-tools-extra')
-rw-r--r-- | clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp index 8bf4c0d84280..ed648897a3aa 100644 --- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp +++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp @@ -104,20 +104,6 @@ llvm::StringRef getFactoryForScale(DurationScale Scale) { 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::MatchResult &Result, const Expr &Node) { // 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; |