[clang] [clang-tools-extra] [llvm] Add ``ignoringParenImpCasts`` in arguments of hasArgument (PR #89553)

Julian Schmidt via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 12:23:42 PDT 2024


================
@@ -36,19 +36,21 @@ void DurationUnnecessaryConversionCheck::registerMatchers(MatchFinder *Finder) {
     // e.g. `absl::ToDoubleSeconds(dur)`.
     auto InverseFunctionMatcher = callExpr(
         callee(functionDecl(hasAnyName(FloatConversion, IntegerConversion))),
-        hasArgument(0, expr().bind("arg")));
+        hasArgument(0, ignoringParenImpCasts(expr().bind("arg"))));
 
     // Matcher which matches a duration divided by the factory_matcher above,
     // e.g. `dur / absl::Seconds(1)`.
     auto DivisionOperatorMatcher = cxxOperatorCallExpr(
-        hasOverloadedOperatorName("/"), hasArgument(0, expr().bind("arg")),
-        hasArgument(1, FactoryMatcher));
+        hasOverloadedOperatorName("/"),
+        hasArgument(0, ignoringParenImpCasts(expr().bind("arg"))),
+        hasArgument(1, ignoringParenImpCasts(FactoryMatcher)));
 
     // Matcher which matches a duration argument to `FDivDuration`,
     // e.g. `absl::FDivDuration(dur, absl::Seconds(1))`
-    auto FdivMatcher = callExpr(
-        callee(functionDecl(hasName("::absl::FDivDuration"))),
-        hasArgument(0, expr().bind("arg")), hasArgument(1, FactoryMatcher));
+    auto FdivMatcher =
+        callExpr(callee(functionDecl(hasName("::absl::FDivDuration"))),
+                 hasArgument(0, ignoringParenImpCasts(expr().bind("arg"))),
+                 hasArgument(1, ignoringParenImpCasts(FactoryMatcher)));
 
----------------
5chmidti wrote:

Please remove the `ignoringParentImpCasts` around the `expr().bind("arg")` matchers, they are not needed.

https://github.com/llvm/llvm-project/pull/89553


More information about the llvm-commits mailing list