[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

Nicolas van Kempen via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 28 13:36:22 PDT 2024


================
@@ -51,6 +53,12 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
   const auto Literal0 = integerLiteral(equals(0));
   const auto Literal1 = integerLiteral(equals(1));
 
+  const auto StringLikeClass = cxxRecordDecl(
+      hasAnyName("::std::basic_string", "::std::basic_string_view",
+                 "::absl::string_view"));
----------------
nicovank wrote:

I'm a fan of not hard-coding any classes when possible. IMO it's fine to match `npos` without checking the DeclContext, it's not a common name.

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


More information about the cfe-commits mailing list