clang-tools  11.0.0
MoveConstructorInitCheck.h
Go to the documentation of this file.
1 //===--- MoveConstructorInitCheck.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_MOVECONSTRUCTORINITCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H
11 
12 #include "../ClangTidyCheck.h"
13 #include "../utils/IncludeInserter.h"
14 
15 #include <memory>
16 
17 namespace clang {
18 namespace tidy {
19 namespace performance {
20 
21 /// The check flags user-defined move constructors that have a ctor-initializer
22 /// initializing a member or base class through a copy constructor instead of a
23 /// move constructor.
24 /// For the user-facing documentation see:
25 /// http://clang.llvm.org/extra/clang-tidy/checks/performance-move-constructor-init.html
27 public:
28  MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context);
29  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30  return LangOpts.CPlusPlus11;
31  }
32  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
33  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
34  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
35  Preprocessor *ModuleExpanderPP) override;
36  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
37 
38 private:
39  std::unique_ptr<utils::IncludeInserter> Inserter;
40  const utils::IncludeSorter::IncludeStyle IncludeStyle;
41 };
42 
43 } // namespace performance
44 } // namespace tidy
45 } // namespace clang
46 
47 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H
clang::tidy::performance::MoveConstructorInitCheck
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
Definition: MoveConstructorInitCheck.h:26
clang::tidy::utils::IncludeSorter::IncludeStyle
IncludeStyle
Supported include styles.
Definition: IncludeSorter.h:26
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:114
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:76
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
clang::tidy::performance::MoveConstructorInitCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: MoveConstructorInitCheck.cpp:29
clang::tidy::bugprone::PP
static Preprocessor * PP
Definition: BadSignalToKillThreadCheck.cpp:29
clang::tidy::performance::MoveConstructorInitCheck::registerPPCallbacks
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
Override this to register PPCallbacks in the preprocessor.
Definition: MoveConstructorInitCheck.cpp:91
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::performance::MoveConstructorInitCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: MoveConstructorInitCheck.cpp:43
clang::tidy::performance::MoveConstructorInitCheck::MoveConstructorInitCheck
MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context)
Definition: MoveConstructorInitCheck.cpp:23
clang::tidy::performance::MoveConstructorInitCheck::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: MoveConstructorInitCheck.h:29
clang::tidy::performance::MoveConstructorInitCheck::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: MoveConstructorInitCheck.cpp:98
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:111