clang-tools 6.0.0

FasterStringFindCheck.h
Go to the documentation of this file.
1 //===--- FasterStringFindCheck.h - clang-tidy--------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_FASTER_STRING_FIND_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_FASTER_STRING_FIND_H
12
13 #include "../ClangTidy.h"
14
15 #include <string>
16 #include <vector>
17
18 namespace clang {
19 namespace tidy {
20 namespace performance {
21
22 /// Optimize calls to std::string::find() and friends when the needle passed is
23 /// a single character string literal.
24 /// The character literal overload is more efficient.
25 ///
26 /// For the user-facing documentation see:
27 /// http://clang.llvm.org/extra/clang-tidy/checks/performance-faster-string-find.html
28 class FasterStringFindCheck : public ClangTidyCheck {
29 public:
30 FasterStringFindCheck(StringRef Name, ClangTidyContext *Context);
31 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
32 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
33 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
34
35 private:
36 const std::vector<std::string> StringLikeClasses;
37 };
38
39 } // namespace performance
40 } // namespace tidy
41 } // namespace clang
42
43 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_FASTER_STRING_FIND_H
clang::tidy::performance::FasterStringFindCheck::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: FasterStringFindCheck.cpp:57
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::performance::FasterStringFindCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: FasterStringFindCheck.cpp:85
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::performance::FasterStringFindCheck
Optimize calls to std::string::find() and friends when the needle passed is a single character string...
Definition: FasterStringFindCheck.h:28
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:99
clang::tidy::performance::FasterStringFindCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: FasterStringFindCheck.cpp:62
clang::tidy::performance::FasterStringFindCheck::FasterStringFindCheck
FasterStringFindCheck(StringRef Name, ClangTidyContext *Context)
Definition: FasterStringFindCheck.cpp:51
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104