[clang-tools-extra] [clang-tidy] Add readability-use-span-first-last check (PR #118074)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 00:09:24 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE LINT COMMENT: clang-tidy-->


:warning: C/C++ code linter, clang-tidy found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

```bash

git diff -U0 origin/main...HEAD -- clang-tools-extra/clang-tidy/readability/UseSpanFirstLastCheck.cpp clang-tools-extra/clang-tidy/readability/UseSpanFirstLastCheck.h clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp |
python3 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py   -path build -p1 -quiet
```

</details>

<details>
<summary>
View the output from clang-tidy here.
</summary>

```


clang-tools-extra/clang-tidy/readability/UseSpanFirstLastCheck.cpp:79:3: warning: variable 'CountText' of type 'StringRef' can be declared 'const' [misc-const-correctness]
   79 |   StringRef CountText = Lexer::getSourceText(
      |   ^
      |             const 
clang-tools-extra/clang-tidy/readability/UseSpanFirstLastCheck.cpp:82:3: warning: variable 'SpanText' of type 'StringRef' can be declared 'const' [misc-const-correctness]
   82 |   StringRef SpanText = Lexer::getSourceText(
      |   ^
      |             const 
clang-tools-extra/clang-tidy/readability/UseSpanFirstLastCheck.cpp:86:3: warning: variable 'Replacement' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
   86 |   std::string Replacement =
      |   ^
      |               const
```

</details>


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


More information about the cfe-commits mailing list