[clang-tools-extra] 9a5af54 - [clang-tidy] Remove readability-deleted-default

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 07:03:47 PDT 2021


Author: Nathan James
Date: 2021-03-16T14:03:33Z
New Revision: 9a5af541ee058b85a92113ecf9d38a06ef2b313d

URL: https://github.com/llvm/llvm-project/commit/9a5af541ee058b85a92113ecf9d38a06ef2b313d
DIFF: https://github.com/llvm/llvm-project/commit/9a5af541ee058b85a92113ecf9d38a06ef2b313d.diff

LOG: [clang-tidy] Remove readability-deleted-default

The deprecation notice was cherrypicked to the release branch in https://github.com/llvm/llvm-project/commit/f8b32989241cca87a8690c8cc404f06ce1f90e4c so its safe to remove this for the 13.X release cycle.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D98612

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/readability/CMakeLists.txt
    clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
    clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp
    clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.h
    clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
    clang-tools-extra/test/clang-tidy/checkers/readability-deleted-default.cpp


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index ecf37b5b9157..78a3851f66be 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -10,7 +10,6 @@ add_clang_library(clangTidyReadabilityModule
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp
-  DeletedDefaultCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionCognitiveComplexityCheck.cpp
   FunctionSizeCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp b/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp
deleted file mode 100644
index ff2f00b94e36..000000000000
--- a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-//===--- DeletedDefaultCheck.cpp - clang-tidy------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "DeletedDefaultCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace readability {
-
-void DeletedDefaultCheck::registerMatchers(MatchFinder *Finder) {
-  // We match constructors/assignment operators that are:
-  //   - explicitly marked '= default'
-  //   - actually deleted
-  //   - not in template instantiation.
-  // We bind the declaration to "method-decl" and also to "constructor" when
-  // it is a constructor.
-
-  Finder->addMatcher(
-      cxxMethodDecl(anyOf(cxxConstructorDecl().bind("constructor"),
-                          isCopyAssignmentOperator(),
-                          isMoveAssignmentOperator()),
-                    isDefaulted(), unless(isImplicit()), isDeleted(),
-                    unless(isInstantiated()))
-          .bind("method-decl"),
-      this);
-}
-
-void DeletedDefaultCheck::check(const MatchFinder::MatchResult &Result) {
-  const StringRef Message = "%0 is explicitly defaulted but implicitly "
-                            "deleted, probably because %1; definition can "
-                            "either be removed or explicitly deleted";
-  if (const auto *Constructor =
-          Result.Nodes.getNodeAs<CXXConstructorDecl>("constructor")) {
-    auto Diag = diag(Constructor->getBeginLoc(), Message);
-    if (Constructor->isDefaultConstructor()) {
-      Diag << "default constructor"
-           << "a non-static data member or a base class is lacking a default "
-              "constructor";
-    } else if (Constructor->isCopyConstructor()) {
-      Diag << "copy constructor"
-           << "a non-static data member or a base class is not copyable";
-    } else if (Constructor->isMoveConstructor()) {
-      Diag << "move constructor"
-           << "a non-static data member or a base class is neither copyable "
-              "nor movable";
-    }
-  } else if (const auto *Assignment =
-                 Result.Nodes.getNodeAs<CXXMethodDecl>("method-decl")) {
-    diag(Assignment->getBeginLoc(), Message)
-        << (Assignment->isCopyAssignmentOperator() ? "copy assignment operator"
-                                                   : "move assignment operator")
-        << "a base class or a non-static data member is not assignable, e.g. "
-           "because the latter is marked 'const'";
-  }
-}
-
-} // namespace readability
-} // namespace tidy
-} // namespace clang

diff  --git a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.h b/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.h
deleted file mode 100644
index ab7f141417d0..000000000000
--- a/clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//===--- DeletedDefaultCheck.h - clang-tidy----------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETED_DEFAULT_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETED_DEFAULT_H
-
-#include "../ClangTidyCheck.h"
-
-namespace clang {
-namespace tidy {
-namespace readability {
-
-/// Checks when a constructor or an assignment operator is marked as '= default'
-/// but is actually deleted by the compiler.
-///
-/// For the user-facing documentation see:
-/// http://clang.llvm.org/extra/clang-tidy/checks/readability-deleted-default.html
-class DeletedDefaultCheck : public ClangTidyCheck {
-public:
-  DeletedDefaultCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context) {}
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-};
-
-} // namespace readability
-} // namespace tidy
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETED_DEFAULT_H

diff  --git a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
index bbd2e24e503b..088b9f09082e 100644
--- a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -15,7 +15,6 @@
 #include "ContainerSizeEmptyCheck.h"
 #include "ConvertMemberFunctionsToStatic.h"
 #include "DeleteNullPointerCheck.h"
-#include "DeletedDefaultCheck.h"
 #include "ElseAfterReturnCheck.h"
 #include "FunctionCognitiveComplexityCheck.h"
 #include "FunctionSizeCheck.h"
@@ -67,8 +66,6 @@ class ReadabilityModule : public ClangTidyModule {
         "readability-convert-member-functions-to-static");
     CheckFactories.registerCheck<DeleteNullPointerCheck>(
         "readability-delete-null-pointer");
-    CheckFactories.registerCheck<DeletedDefaultCheck>(
-        "readability-deleted-default");
     CheckFactories.registerCheck<ElseAfterReturnCheck>(
         "readability-else-after-return");
     CheckFactories.registerCheck<FunctionCognitiveComplexityCheck>(

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 91207090902d..d9625db3f99e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -112,11 +112,10 @@ Changes in existing checks
   function or assignment to ``nullptr``.
   Added support for pointers to ``std::unique_ptr``.
 
-Deprecated checks
-^^^^^^^^^^^^^^^^^
+Removed checks
+^^^^^^^^^^^^^^
 
-- The :doc:`readability-deleted-default
-  <clang-tidy/checks/readability-deleted-default>` check has been deprecated.
+- The readability-deleted-default check has been removed.
   
   The clang warning `Wdefaulted-function-deleted
   <https://clang.llvm.org/docs/DiagnosticsReference.html#wdefaulted-function-deleted>`_

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index e53c0e704963..bda9cc1aa015 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -280,7 +280,6 @@ Clang-Tidy Checks
    `readability-container-size-empty <readability-container-size-empty.html>`_, "Yes"
    `readability-convert-member-functions-to-static <readability-convert-member-functions-to-static.html>`_,
    `readability-delete-null-pointer <readability-delete-null-pointer.html>`_, "Yes"
-   `readability-deleted-default <readability-deleted-default.html>`_,
    `readability-else-after-return <readability-else-after-return.html>`_, "Yes"
    `readability-function-cognitive-complexity <readability-function-cognitive-complexity.html>`_,
    `readability-function-size <readability-function-size.html>`_,

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
deleted file mode 100644
index 5f2083e00061..000000000000
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-.. title:: clang-tidy - readability-deleted-default
-
-readability-deleted-default
-===========================
-
-This check has been deprecated prefer to make use of the `Wdefaulted-function-deleted
-<https://clang.llvm.org/docs/DiagnosticsReference.html#wdefaulted-function-deleted>`_
-flag.

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/readability-deleted-default.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-deleted-default.cpp
deleted file mode 100644
index 232f224128a6..000000000000
--- a/clang-tools-extra/test/clang-tidy/checkers/readability-deleted-default.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-// RUN: %check_clang_tidy %s readability-deleted-default %t -- -- -fno-ms-compatibility
-
-class NoDefault {
-public:
-  NoDefault() = delete;
-  NoDefault(NoDefault &&Other) = delete;
-  NoDefault(const NoDefault &Other) = delete;
-};
-
-class MissingEverything {
-public:
-  MissingEverything() = default;
-  // CHECK-MESSAGES: warning: default constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is lacking a default constructor; definition can either be removed or explicitly deleted [readability-deleted-default]
-  MissingEverything(MissingEverything &&Other) = default;
-  // CHECK-MESSAGES: warning: move constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is neither copyable nor movable; definition can either be removed or explicitly deleted [readability-deleted-default]
-  MissingEverything(const MissingEverything &Other) = default;
-  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is not copyable; definition can either be removed or explicitly deleted [readability-deleted-default]
-  MissingEverything &operator=(MissingEverything &&Other) = default;
-  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
-  MissingEverything &operator=(const MissingEverything &Other) = default;
-  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
-
-private:
-  NoDefault ND;
-};
-
-class NotAssignable {
-public:
-  NotAssignable(NotAssignable &&Other) = default;
-  NotAssignable(const NotAssignable &Other) = default;
-  NotAssignable &operator=(NotAssignable &&Other) = default;
-  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted
-  NotAssignable &operator=(const NotAssignable &Other) = default;
-  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
-
-private:
-  const int I = 0;
-};
-
-class Movable {
-public:
-  Movable() = default;
-  Movable(Movable &&Other) = default;
-  Movable(const Movable &Other) = delete;
-  Movable &operator=(Movable &&Other) = default;
-  Movable &operator=(const Movable &Other) = delete;
-};
-
-class NotCopyable {
-public:
-  NotCopyable(NotCopyable &&Other) = default;
-  NotCopyable(const NotCopyable &Other) = default;
-  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted
-  NotCopyable &operator=(NotCopyable &&Other) = default;
-  NotCopyable &operator=(const NotCopyable &Other) = default;
-  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
-private:
-  Movable M;
-};
-
-template <typename T> class Templated {
-public:
-  // No warning here, it is a templated class.
-  Templated() = default;
-  Templated(Templated &&Other) = default;
-  Templated(const Templated &Other) = default;
-  Templated &operator=(Templated &&Other) = default;
-  Templated &operator=(const Templated &Other) = default;
-
-  class InnerTemplated {
-  public:
-    // This class is not in itself templated, but we still don't have warning.
-    InnerTemplated() = default;
-    InnerTemplated(InnerTemplated &&Other) = default;
-    InnerTemplated(const InnerTemplated &Other) = default;
-    InnerTemplated &operator=(InnerTemplated &&Other) = default;
-    InnerTemplated &operator=(const InnerTemplated &Other) = default;
-
-  private:
-    T TVar;
-  };
-
-  class InnerNotTemplated {
-  public:
-    // This one could technically have warnings, but currently doesn't.
-    InnerNotTemplated() = default;
-    InnerNotTemplated(InnerNotTemplated &&Other) = default;
-    InnerNotTemplated(const InnerNotTemplated &Other) = default;
-    InnerNotTemplated &operator=(InnerNotTemplated &&Other) = default;
-    InnerNotTemplated &operator=(const InnerNotTemplated &Other) = default;
-
-  private:
-    int I;
-  };
-
-private:
-  const T TVar{};
-};
-
-int FunctionWithInnerClass() {
-  class InnerNotAssignable {
-  public:
-    InnerNotAssignable &operator=(InnerNotAssignable &&Other) = default;
-    // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted
-  private:
-    const int I = 0;
-  };
-  return 1;
-};
-
-template <typename T>
-int TemplateFunctionWithInnerClass() {
-  class InnerNotAssignable {
-  public:
-    InnerNotAssignable &operator=(InnerNotAssignable &&Other) = default;
-  private:
-    const T TVar{};
-  };
-  return 1;
-};
-
-void Foo() {
-  Templated<const int> V1;
-  Templated<int>::InnerTemplated V2;
-  Templated<float>::InnerNotTemplated V3;
-  TemplateFunctionWithInnerClass<int>();
-}


        


More information about the cfe-commits mailing list