[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:45 PDT 2024


================
@@ -44,9 +44,10 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder *Finder) {
       callee(cxxMethodDecl(hasName("find")).bind("findfun")),
       on(hasType(StringType)),
       // ... with some search expression ...
-      hasArgument(0, expr().bind("needle")),
+      hasArgument(0, expr().ignoringParenImpCasts().bind("needle")),
----------------
5chmidti wrote:

There is also no need to add `ignoringParenImpCasts` to `needle`. All the needle node is used for is to get the source code, which does not care if we are at an implicit node or not (ln. 88, 103-104, 123). Leaving out the `ignoringParenImpCasts` will also keep a user's parentheses in-place, if they wrote them.

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


More information about the llvm-commits mailing list