[clang-tools-extra] d4e8109 - [clang-tidy] Skip variadic ctors in modernize-use-equals-default

Alexander Shaposhnikov via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 30 15:16:58 PDT 2022


Author: Alexander Shaposhnikov
Date: 2022-09-30T22:16:28Z
New Revision: d4e81097ea3daf37b5480281a17ad5b20cd7ee8d

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

LOG: [clang-tidy] Skip variadic ctors in modernize-use-equals-default

Skip variadic constructors in modernize-use-equals-default
(such constructors cannot be explicitly defaulted).

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D134929

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
index d5c402c4bdeb7..165840b72e7aa 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -235,7 +235,7 @@ void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
           anyOf(
               // Default constructor.
               allOf(unless(hasAnyConstructorInitializer(isWritten())),
-                    parameterCountIs(0)),
+                    unless(isVariadic()), parameterCountIs(0)),
               // Copy constructor.
               allOf(isCopyConstructor(),
                     // Discard constructors that can be used as a copy

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 9447cbfba73e0..8e65ed214a21d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,9 +145,9 @@ Changes in existing checks
   check.
 
   The check now skips unions/union-like classes since in this case a default constructor
-  with empty body is not equivalent to the explicitly defaulted one. The check also skips
-  copy assignment operators with nonstandard return types. The check is restricted to
-  c++11-or-later.
+  with empty body is not equivalent to the explicitly defaulted one, variadic constructors
+  since they cannot be explicitly defaulted. The check also skips copy assignment operators
+  with nonstandard return types. The check is restricted to c++11-or-later.
 
 - Change the default behavior of :doc:`readability-avoid-const-params-in-decls
   <clang-tidy/checks/readability/avoid-const-params-in-decls>` to not

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
index ba252792cf3a6..493cfa21a8371 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
@@ -53,6 +53,11 @@ struct SU {
   };
 };
 
+// Skip variadic constructors.
+struct VA {
+  VA(...) {}
+};
+
 // Initializer or arguments.
 class IA {
 public:


        


More information about the cfe-commits mailing list