[clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro
authorKonrad Kleine <kkleine@redhat.com>
Wed, 3 Jun 2020 20:53:43 +0000 (16:53 -0400)
committerKonrad Kleine <kkleine@redhat.com>
Wed, 3 Jun 2020 20:56:03 +0000 (16:56 -0400)
commite636e6b79ac06b13059e46b49acb4d9de204c75b
treecf636be146798e8579ca19259cd5994a5ccd929c
parent66251f7e1de79a7c1620659b7f58352b8c8e892e
[clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

Summary:
This check finds macro expansions of `DISALLOW_COPY_AND_ASSIGN(Type)` and
replaces them with a deleted copy constructor and a deleted assignment operator.

Before the `delete` keyword was introduced in C++11 it was common practice to
declare a copy constructor and an assignment operator as a private members. This
effectively makes them unusable to the public API of a class.

With the advent of the `delete` keyword in C++11 we can abandon the
`private` access of the copy constructor and the assignment operator and
delete the methods entirely.

Migration example:

```
lang=dif
class Foo {
  private:
  -  DISALLOW_COPY_AND_ASSIGN(Foo);
  +  Foo(const Foo &) = delete;
  +  const Foo &operator=(const Foo &) = delete;
  };
```

Reviewers: alexfh, hokein, aaron.ballman, njames93

Reviewed By: njames93

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D80531
clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h [new file with mode: 0644]
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp [new file with mode: 0644]