[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 21 15:54:24 PST 2024


================
@@ -240,6 +240,9 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) {
                                        ReplacementFunction->getName());
 
   // Replace arguments and everything after the function call.
+  if (FindExpr->getNumArgs() == 0) {
+    return;
+  }
----------------
5chmidti wrote:

Technically all matchers that bind `find_expr` do bind on a call with more than one argument, but we can leave this in. IMO this should be moved before any fixes are added to the diagnostic, otherwise there will be a partial fix attached to the diagnostic. 

nit: single expr as *then* -> no braces around the return

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


More information about the cfe-commits mailing list