[clang-tools-extra] [clang-tidy] Extend `performance-faster-string-find` to handle ternary operator arguments (PR #187069)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 22 11:37:23 PDT 2026
================
@@ -55,8 +61,7 @@ void FasterStringFindCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
}
void FasterStringFindCheck::registerMatchers(MatchFinder *Finder) {
- const auto SingleChar =
- ignoringParenCasts(stringLiteral(hasSize(1)).bind("literal"));
+ const auto SingleChar = expr().bind("literal");
----------------
localspook wrote:
I don't really like that we would be introducing repetition into the code
I could stick this part:
```cpp
if (!utils::forAllLeavesOfTernaryTree(Literal, [](const Expr *E) {
const auto *Literal = dyn_cast<StringLiteral>(E);
return Literal && Literal->getLength() == 1;
}))
return;
```
into a custom matcher though
https://github.com/llvm/llvm-project/pull/187069
More information about the cfe-commits
mailing list