• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
26 class MoveConstructorInitCheck : public ClangTidyCheck {
27 public:
28   MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context);
isLanguageVersionSupported(const LangOptions & LangOpts)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   utils::IncludeInserter Inserter;
40 };
41 
42 } // namespace performance
43 } // namespace tidy
44 } // namespace clang
45 
46 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H
47