59 lines · c
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACEDISALLOWCOPYANDASSIGNMACROCHECK_H10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACEDISALLOWCOPYANDASSIGNMACROCHECK_H11 12#include "../ClangTidyCheck.h"13 14namespace clang::tidy::modernize {15 16/// This check finds macro expansions of ``DISALLOW_COPY_AND_ASSIGN(Type)`` and17/// replaces them with a deleted copy constructor and a deleted assignment18/// 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/// https://clang.llvm.org/extra/clang-tidy/checks/modernize/replace-disallow-copy-and-assign-macro.html39class ReplaceDisallowCopyAndAssignMacroCheck : public ClangTidyCheck {40public:41 ReplaceDisallowCopyAndAssignMacroCheck(StringRef Name,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::modernize57 58#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACEDISALLOWCOPYANDASSIGNMACROCHECK_H59