clang-tools 20.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
14namespace clang::tidy::modernize {
15
16/// This check finds macro expansions of ``DISALLOW_COPY_AND_ASSIGN(Type)`` and
17/// replaces them with a deleted copy constructor and a deleted assignment
18/// operator.
19///
20/// Before:
21/// ~~~{.cpp}
22/// class Foo {
23/// private:
24/// DISALLOW_COPY_AND_ASSIGN(Foo);
25/// };
26/// ~~~
27///
28/// After:
29/// ~~~{.cpp}
30/// class Foo {
31/// private:
32/// Foo(const Foo &) = delete;
33/// const Foo &operator=(const Foo &) = delete;
34/// };
35/// ~~~
36///
37/// For the user-facing documentation see:
38/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/replace-disallow-copy-and-assign-macro.html
40public:
42 ClangTidyContext *Context);
43 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
44 return LangOpts.CPlusPlus11;
45 }
46 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
47 Preprocessor *ModuleExpanderPP) override;
48 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
49
50 const StringRef &getMacroName() const { return MacroName; }
51
52private:
53 const StringRef MacroName;
54};
55
56} // namespace clang::tidy::modernize
57
58#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACEDISALLOWCOPYANDASSIGNMACROCHECK_H
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
This check finds macro expansions of DISALLOW_COPY_AND_ASSIGN(Type) and replaces them with a deleted ...
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
Override this to register PPCallbacks in the preprocessor.
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
llvm::StringMap< ClangTidyValue > OptionMap