[clang-tools-extra] [clang-tidy] Add modernize-substr-to-starts-with check (PR #116033)
Nicolas van Kempen via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 13 09:20:45 PST 2024
================
----------------
nicovank wrote:
FWIW I think it's a good idea in modernize-use-starts-ends-with documentation to use a table as in [readability-container-contains](https://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html).
Here is a table with the current examples:
```
==================================================== ===========================
Expression Result
---------------------------------------------------- ---------------------------
``u.find(v) == 0`` ``u.starts_with(v)``
``u.rfind(v, 0) != 0`` ``!u.starts_with(v)``
``u.compare(0, v.size(), v) == 0`` ``u.starts_with(v)``
``u.compare(u.size() - v.size(), v.size(), v) == 0`` ``u.ends_with(v)``
``u.rfind(v) == u.size() - 6`` ``u.ends_with(v)``
==================================================== ===========================
```
https://github.com/llvm/llvm-project/pull/116033
More information about the cfe-commits
mailing list