[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)
Helmut Januschka via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 29 02:14:43 PST 2024
hjanuschka wrote:
@carlosgalvezp thanks for the feedback. I've removed the transformation:
```c++
auto sub2 = s.subspan(n); // transforms to: auto sub2 = s.last(s.size() - n);
```
While I agree that the transformed expression is more complex (due to size() - x), I initially included it for two reasons:
Consistency: Using `first()/last()` everywhere possible makes the codebase more uniform
The method name `last()` better expresses the intent than `subspan()`, even if the calculation is more verbose
Let me know if you think we should revisit this decision.
https://github.com/llvm/llvm-project/pull/118074
More information about the cfe-commits
mailing list