clang-tools  14.0.0git
ReplaceDisallowCopyAndAssignMacroCheck.h
Go to the documentation of this file.
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
42 public:
44  ClangTidyContext *Context);
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 
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
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:115
clang::tidy::modernize::ReplaceDisallowCopyAndAssignMacroCheck::getMacroName
const std::string & getMacroName() const
Definition: ReplaceDisallowCopyAndAssignMacroCheck.h:52
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:54
clang::tidy::modernize::ReplaceDisallowCopyAndAssignMacroCheck::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: ReplaceDisallowCopyAndAssignMacroCheck.cpp:85
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:72
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::modernize::ReplaceDisallowCopyAndAssignMacroCheck::registerPPCallbacks
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
Override this to register PPCallbacks in the preprocessor.
Definition: ReplaceDisallowCopyAndAssignMacroCheck.cpp:78
clang::tidy::bugprone::PP
static Preprocessor * PP
Definition: BadSignalToKillThreadCheck.cpp:29
clang::tidy::modernize::ReplaceDisallowCopyAndAssignMacroCheck
This check finds macro expansions of DISALLOW_COPY_AND_ASSIGN(Type) and replaces them with a deleted ...
Definition: ReplaceDisallowCopyAndAssignMacroCheck.h:41
clang::tidy::modernize::ReplaceDisallowCopyAndAssignMacroCheck::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: ReplaceDisallowCopyAndAssignMacroCheck.h:45
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::modernize::ReplaceDisallowCopyAndAssignMacroCheck::ReplaceDisallowCopyAndAssignMacroCheck
ReplaceDisallowCopyAndAssignMacroCheck(StringRef Name, ClangTidyContext *Context)
Definition: ReplaceDisallowCopyAndAssignMacroCheck.cpp:73