1bcf23661SMalcolm Parsons //===--- UseEqualsDefaultCheck.h - clang-tidy--------------------------*- C++ -*-===// 2bcf23661SMalcolm Parsons // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6bcf23661SMalcolm Parsons // 7bcf23661SMalcolm Parsons //===----------------------------------------------------------------------===// 8bcf23661SMalcolm Parsons 9bcf23661SMalcolm Parsons #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DEFAULT_H 10bcf23661SMalcolm Parsons #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DEFAULT_H 11bcf23661SMalcolm Parsons 12478fc5c8SAlexander Kornienko #include "../ClangTidyCheck.h" 13bcf23661SMalcolm Parsons 14*4718da50SCarlos Galvez namespace clang::tidy::modernize { 15bcf23661SMalcolm Parsons 16282dc72cSDmitri Gribenko /// Replace default bodies of special member functions with '= default;'. 17bcf23661SMalcolm Parsons /// \code 18bcf23661SMalcolm Parsons /// struct A { 19bcf23661SMalcolm Parsons /// A() {} 20bcf23661SMalcolm Parsons /// ~A(); 21bcf23661SMalcolm Parsons /// }; 22bcf23661SMalcolm Parsons /// A::~A() {} 23bcf23661SMalcolm Parsons /// \endcode 24bcf23661SMalcolm Parsons /// Is converted to: 25bcf23661SMalcolm Parsons /// \code 26bcf23661SMalcolm Parsons /// struct A { 27bcf23661SMalcolm Parsons /// A() = default; 28bcf23661SMalcolm Parsons /// ~A(); 29bcf23661SMalcolm Parsons /// }; 30bcf23661SMalcolm Parsons /// A::~A() = default; 31bcf23661SMalcolm Parsons /// \endcode 32bcf23661SMalcolm Parsons /// 33bcf23661SMalcolm Parsons /// For the user-facing documentation see: 346e566bc5SRichard /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html 35bcf23661SMalcolm Parsons class UseEqualsDefaultCheck : public ClangTidyCheck { 36bcf23661SMalcolm Parsons public: 37dea43983SAlexander Kornienko UseEqualsDefaultCheck(StringRef Name, ClangTidyContext *Context); isLanguageVersionSupported(const LangOptions & LangOpts)38e40a742aSNathan James bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { 3947dbacbcSAlexander Shaposhnikov return LangOpts.CPlusPlus11; 40e40a742aSNathan James } 41dea43983SAlexander Kornienko void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 42bcf23661SMalcolm Parsons void registerMatchers(ast_matchers::MatchFinder *Finder) override; 43bcf23661SMalcolm Parsons void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 44dea43983SAlexander Kornienko 45dea43983SAlexander Kornienko private: 46dea43983SAlexander Kornienko const bool IgnoreMacros; 47bcf23661SMalcolm Parsons }; 48bcf23661SMalcolm Parsons 49*4718da50SCarlos Galvez } // namespace clang::tidy::modernize 50bcf23661SMalcolm Parsons 51bcf23661SMalcolm Parsons #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DEFAULT_H 52