[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


================
@@ -171,10 +182,26 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
                              hasRHS(lengthExprForStringNode("needle")))))
           .bind("expr"),
       this);
+
+  // Case 6: X.substr(0, LEN(Y)) [!=]= Y -> ends_with.
----------------
5chmidti wrote:

`ends_with` -> `starts_with`. The `substr` is always anchored at `0`

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


More information about the cfe-commits mailing list