clang-tools  14.0.0git
StringFindStrContainsCheck.h
Go to the documentation of this file.
1 //===--- StringFindStrContainsCheck.h - clang-tidy---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_STRINGFINDSTRCONTAINSCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_STRINGFINDSTRCONTAINSCHECK_H
11 
12 #include "../ClangTidyCheck.h"
13 #include "../utils/TransformerClangTidyCheck.h"
14 
15 namespace clang {
16 namespace tidy {
17 namespace abseil {
18 
19 /// Finds s.find(...) == string::npos comparisons (for various string-like
20 /// types) and suggests replacing with absl::StrContains.
21 ///
22 /// For the user-facing documentation see:
23 /// http://clang.llvm.org/extra/clang-tidy/checks/abseil-string-find-str-contains.html
25 public:
27  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
28  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
29 
30 private:
31  const std::vector<std::string> StringLikeClassesOption;
32  const std::string AbseilStringsMatchHeaderOption;
33 };
34 
35 } // namespace abseil
36 } // namespace tidy
37 } // namespace clang
38 
39 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_STRINGFINDSTRCONTAINSCHECK_H
clang::tidy::abseil::StringFindStrContainsCheck
Finds s.find(...) == string::npos comparisons (for various string-like types) and suggests replacing ...
Definition: StringFindStrContainsCheck.h:24
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:115
clang::tidy::abseil::StringFindStrContainsCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: StringFindStrContainsCheck.cpp:102
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:71
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::abseil::StringFindStrContainsCheck::StringFindStrContainsCheck
StringFindStrContainsCheck(StringRef Name, ClangTidyContext *Context)
Definition: StringFindStrContainsCheck.cpp:86
clang::tidy::utils::TransformerClangTidyCheck
A base class for defining a ClangTidy check based on a RewriteRule.
Definition: TransformerClangTidyCheck.h:39
clang::tidy::abseil::StringFindStrContainsCheck::isLanguageVersionSupported
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
Definition: StringFindStrContainsCheck.cpp:97
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27