[clang-tools-extra] [clang-tidy][NFC][doc] Improve documentation for modernize-use-equals… (PR #65231)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 3 11:57:28 PDT 2023


Carlos =?utf-8?q?Gálvez?= <carlos.galvez at zenseact.com>,
Carlos =?utf-8?q?Gálvez?= <carlos.galvez at zenseact.com>,
Carlos =?utf-8?q?Gálvez?= <carlos.galvez at zenseact.com>,
Carlos =?utf-8?q?Gálvez?= <carlos.galvez at zenseact.com>


================
@@ -3,22 +3,37 @@
 modernize-use-equals-delete
 ===========================
 
-This check marks unimplemented private special member functions with ``= delete``.
-To avoid false-positives, this check only applies in a translation unit that has
-all other member functions implemented.
-
-.. code-block:: c++
-
-  struct A {
-  private:
+Identifies unimplemented private special member functions, and recommends using
+``= delete`` for them, as well as relocating them from the ``private`` to the
+``public`` section.
+
+Before the introduction of C++11, the primary method to effectively "erase" a
+particular function involved declaring it as ``private`` without providing a
+definition. This approach would result in either a compiler error (when
+attempting to call a private function) or a linker error (due to an undefined
+reference).
+
+However, subsequent to the advent of C++11, a more conventional approach emerged
+for achieving this purpose. It involves flagging functions as ``= delete`` and
+keeping them in the ``public`` section of the class.
+
+To prevent false positives, this check is only active within a translation
+unit where all other member functions have been implemented. The check will
+generate partial fixes by introducing ``= delete``, but the user is responsible
+for manually relocating functions to the ``public`` section.
+
+.. code-block:: c
+
+  // Example: bad
+  class A {
+   private:
     A(const A&);
     A& operator=(const A&);
   };
 
-  // becomes
-
-  struct A {
-  private:
+  // Example: good
+  class A {
+   public:
     A(const A&) = delete;
     A& operator=(const A&) = delete;
   };
----------------
PiotrZSL wrote:

Ach, didnt see it, had to click button to load rest of diff, then it's fine...

https://github.com/llvm/llvm-project/pull/65231


More information about the cfe-commits mailing list