[clang-tools-extra] [clang-tidy] Add readability-string-view-substr check (PR #120055)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 01:09:14 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/StringViewSubstrCheck.cpp clang-tools-extra/clang-tidy/readability/StringViewSubstrCheck.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/StringViewSubstrCheck.cpp:108:5: warning: variable 'PrefixText' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
108 | std::string PrefixText =
| ^
| const
clang-tools-extra/clang-tidy/readability/StringViewSubstrCheck.cpp:114:5: warning: variable 'Replacement' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
114 | std::string Replacement = TargetName + ".remove_prefix(" + PrefixText + ")";
| ^
| const
clang-tools-extra/clang-tidy/readability/StringViewSubstrCheck.cpp:134:7: warning: variable 'EndLoc' of type 'SourceLocation' can be declared 'const' [misc-const-correctness]
134 | SourceLocation EndLoc = Lexer::findLocationAfterToken(
| ^
| const
clang-tools-extra/clang-tidy/readability/StringViewSubstrCheck.cpp:145:7: warning: variable 'Replacement' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
145 | std::string Replacement = TargetName + " = " + SourceName;
| ^
| const
clang-tools-extra/clang-tidy/readability/StringViewSubstrCheck.cpp:163:5: warning: variable 'SuffixText' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
163 | std::string SuffixText =
| ^
| const
clang-tools-extra/clang-tidy/readability/StringViewSubstrCheck.cpp:170:7: warning: variable 'Replacement' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
170 | std::string Replacement =
| ^
| const
clang-tools-extra/clang-tidy/readability/StringViewSubstrCheck.cpp:177:7: warning: variable 'Replacement' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
177 | std::string Replacement = TargetName + " = " + SourceName + ";\n" + " " +
| ^
| const
```
</details>
https://github.com/llvm/llvm-project/pull/120055
More information about the cfe-commits
mailing list