[clang-tools-extra] [clang-tidy] Add performance-substr-self-assignment check (PR #209657)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 15 08:53:10 PDT 2026
================
@@ -97,6 +97,13 @@ Improvements to clang-tidy
New checks
^^^^^^^^^^
+- New :doc:`performance-substr-self-assignment
+ <clang-tidy/checks/performance/substr-self-assignment>` check.
+
+ Finds cases where a string variable is assigned the result of calling
+ ``substr()`` on itself, which creates an unnecessary temporary. Suggests
+ using ``erase()`` to modify the string in-place instead.
----------------
EugeneZelenko wrote:
```suggestion
``substr()`` on itself.
```
https://github.com/llvm/llvm-project/pull/209657
More information about the cfe-commits
mailing list