1 //===--- ReplaceDisallowCopyAndAssignMacroCheck.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_MODERNIZE_REPLACEDISALLOWCOPYANDASSIGNMACROCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACEDISALLOWCOPYANDASSIGNMACROCHECK_H
11 
12 #include "../ClangTidyCheck.h"
13 
14 namespace clang {
15 namespace tidy {
16 namespace modernize {
17 
18 /// This check finds macro expansions of ``DISALLOW_COPY_AND_ASSIGN(Type)`` and
19 /// replaces them with a deleted copy constructor and a deleted assignment
20 /// operator.
21 ///
22 /// Before:
23 /// ~~~{.cpp}
24 ///   class Foo {
25 ///   private:
26 ///     DISALLOW_COPY_AND_ASSIGN(Foo);
27 ///   };
28 /// ~~~
29 ///
30 /// After:
31 /// ~~~{.cpp}
32 ///   class Foo {
33 ///   private:
34 ///     Foo(const Foo &) = delete;
35 ///     const Foo &operator=(const Foo &) = delete;
36 ///   };
37 /// ~~~
38 ///
39 /// For the user-facing documentation see:
40 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.html
41 class ReplaceDisallowCopyAndAssignMacroCheck : public ClangTidyCheck {
42 public:
43   ReplaceDisallowCopyAndAssignMacroCheck(StringRef Name,
44                                          ClangTidyContext *Context);
isLanguageVersionSupported(const LangOptions & LangOpts)45   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
46     return LangOpts.CPlusPlus11;
47   }
48   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
49                            Preprocessor *ModuleExpanderPP) override;
50   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
51 
getMacroName()52   const std::string &getMacroName() const { return MacroName; }
53 
54 private:
55   const std::string MacroName;
56 };
57 
58 } // namespace modernize
59 } // namespace tidy
60 } // namespace clang
61 
62 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACEDISALLOWCOPYANDASSIGNMACROCHECK_H
63