| 1 |
//===--- UseEqualsDeleteCheck.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_USE_EQUALS_DELETE_H |
| 10 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DELETE_H |
| 11 |
|
| 12 |
#include "../ClangTidyCheck.h" |
| 13 |
|
| 14 |
namespace clang::tidy::modernize { |
| 15 |
|
| 16 |
/// Mark unimplemented private special member functions with '= delete'. |
| 17 |
/// \code |
| 18 |
/// struct A { |
| 19 |
/// private: |
| 20 |
/// A(const A&); |
| 21 |
/// A& operator=(const A&); |
| 22 |
/// }; |
| 23 |
/// \endcode |
| 24 |
/// Is converted to: |
| 25 |
/// \code |
| 26 |
/// struct A { |
| 27 |
/// private: |
| 28 |
/// A(const A&) = delete; |
| 29 |
/// A& operator=(const A&) = delete; |
| 30 |
/// }; |
| 31 |
/// \endcode |
| 32 |
/// |
| 33 |
/// For the user-facing documentation see: |
| 34 |
/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-delete.html |
| 35 |
class UseEqualsDeleteCheck : public ClangTidyCheck { |
| 36 |
public: |
| 37 |
UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context) |
| 38 |
: ClangTidyCheck(Name, Context), |
| 39 |
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {} |
| 40 |
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { |
| 41 |
return LangOpts.CPlusPlus; |
| 42 |
} |
| 43 |
void storeOptions(ClangTidyOptions::OptionMap &Opts) override; |
| 44 |
void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 45 |
void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 46 |
|
| 47 |
private: |
| 48 |
const bool IgnoreMacros; |
| 49 |
}; |
| 50 |
|
| 51 |
} // namespace clang::tidy::modernize |
| 52 |
|
| 53 |
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DELETE_H |