[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)
Helmut Januschka via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 12:52:56 PST 2024
================
@@ -173,7 +222,80 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
this);
}
+void UseStartsEndsWithCheck::handleSubstrMatch(const MatchFinder::MatchResult &Result) {
+ const auto *SubstrCall = Result.Nodes.getNodeAs<CXXMemberCallExpr>("substr_fun");
+ const auto *PositiveComparison = Result.Nodes.getNodeAs<Expr>("positiveComparison");
+ const auto *NegativeComparison = Result.Nodes.getNodeAs<Expr>("negativeComparison");
+
+ if (!SubstrCall || (!PositiveComparison && !NegativeComparison))
+ return;
+
+ bool Negated = NegativeComparison != nullptr;
----------------
hjanuschka wrote:
done
https://github.com/llvm/llvm-project/pull/116033
More information about the cfe-commits
mailing list