void FasterStringFindCheck::registerMatchers(MatchFinder *Finder) {
  if (!getLangOpts().CPlusPlus)
    return;

  const auto SingleChar =
      expr(ignoringParenCasts(stringLiteral(hasSize(1)).bind("literal")));

  const auto StringFindFunctions =
      anyOf(hasName("find"), hasName("rfind"), hasName("find_first_of"),
            hasName("find_first_not_of"), hasName("find_last_of"),
            hasName("find_last_not_of"));

  llvm::Optional<ast_matchers::internal::Matcher<NamedDecl>> IsStringClass;

  for (const auto &ClassName : StringLikeClasses) {
    const auto HasName = hasName(ClassName);
    IsStringClass = IsStringClass ? anyOf(*IsStringClass, HasName) : HasName;
  }

  if (IsStringClass) {
    Finder->addMatcher(
        cxxMemberCallExpr(
            callee(functionDecl(StringFindFunctions).bind("func")),
            anyOf(argumentCountIs(1), argumentCountIs(2)),
            hasArgument(0, SingleChar),
            on(expr(hasType(recordDecl(*IsStringClass)),
                    unless(hasSubstitutedType())))),
        this);
  }
}
void FasterStringFindCheck::registerMatchers(MatchFinder *Finder) {
  if (!getLangOpts().CPlusPlus)
    return;

  const auto SingleChar =
      expr(ignoringParenCasts(stringLiteral(hasSize(1)).bind("literal")));
  const auto StringFindFunctions =
      hasAnyName("find", "rfind", "find_first_of", "find_first_not_of",
                 "find_last_of", "find_last_not_of");

  Finder->addMatcher(
      cxxMemberCallExpr(
          callee(functionDecl(StringFindFunctions).bind("func")),
          anyOf(argumentCountIs(1), argumentCountIs(2)),
          hasArgument(0, SingleChar),
          on(expr(
              hasType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(
                  recordDecl(hasAnyName(SmallVector<StringRef, 4>(
                      StringLikeClasses.begin(), StringLikeClasses.end()))))))),
              unless(hasSubstitutedType())))),
      this);
}