clang-tools  12.0.0git
FasterStringFindCheck.h
Go to the documentation of this file.
1 //===--- FasterStringFindCheck.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_PERFORMANCE_FASTER_STRING_FIND_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_FASTER_STRING_FIND_H
11 
12 #include "../ClangTidyCheck.h"
13 
14 #include <string>
15 #include <vector>
16 
17 namespace clang {
18 namespace tidy {
19 namespace performance {
20 
21 /// Optimize calls to std::string::find() and friends when the needle passed is
22 /// a single character string literal.
23 /// The character literal overload is more efficient.
24 ///
25 /// For the user-facing documentation see:
26 /// http://clang.llvm.org/extra/clang-tidy/checks/performance-faster-string-find.html
28 public:
29  FasterStringFindCheck(StringRef Name, ClangTidyContext *Context);
30  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override{
31  return LangOpts.CPlusPlus;
32  }
33  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
36 
37 private:
38  const std::vector<std::string> StringLikeClasses;
39 };
40 
41 } // namespace performance
42 } // namespace tidy
43 } // namespace clang
44 
45 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_FASTER_STRING_FIND_H
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Base class for all clang-tidy checks.
Optimize calls to std::string::find() and friends when the needle passed is a single character string...
static constexpr llvm::StringLiteral Name
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
FasterStringFindCheck(StringRef Name, ClangTidyContext *Context)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
std::map< std::string, ClangTidyValue > OptionMap