[PATCH] clang-tidy explicit constructor check: don't warn on copy or move constructors.

Alexander Kornienko alexfh at google.com
Wed Mar 19 15:03:09 PDT 2014


  Don't warn on deleted constructions. Added a test for deleted non-copy or move constructor.

Hi klimek,

http://llvm-reviews.chandlerc.com/D3122

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D3122?vs=7955&id=7965#toc

Files:
  clang-tidy/google/GoogleTidyModule.cpp
  unittests/clang-tidy/GoogleModuleTest.cpp

Index: clang-tidy/google/GoogleTidyModule.cpp
===================================================================
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -34,7 +34,7 @@
   // Do not be confused: isExplicit means 'explicit' keyword is present,
   // isImplicit means that it's a compiler-generated constructor.
   if (Ctor->isOutOfLine() || Ctor->isExplicit() || Ctor->isImplicit() ||
-      Ctor->isDeleted())
+      Ctor->isDeleted() || Ctor->isCopyOrMoveConstructor())
     return;
   if (Ctor->getNumParams() == 0 || Ctor->getMinRequiredArguments() > 1)
     return;
Index: unittests/clang-tidy/GoogleModuleTest.cpp
===================================================================
--- unittests/clang-tidy/GoogleModuleTest.cpp
+++ unittests/clang-tidy/GoogleModuleTest.cpp
@@ -12,8 +12,12 @@
 TEST(ExplicitConstructorCheckTest, SingleArgumentConstructorsOnly) {
   EXPECT_NO_CHANGES(ExplicitConstructorCheck, "class C { C(); };");
   EXPECT_NO_CHANGES(ExplicitConstructorCheck, "class C { C(int i, int j); };");
+  EXPECT_NO_CHANGES(ExplicitConstructorCheck, "class C { C(const C&); };");
+  EXPECT_NO_CHANGES(ExplicitConstructorCheck, "class C { C(C&&); };");
   EXPECT_NO_CHANGES(ExplicitConstructorCheck,
                     "class C { C(const C&) = delete; };");
+  EXPECT_NO_CHANGES(ExplicitConstructorCheck,
+                    "class C { C(int) = delete; };");
 }
 
 TEST(ExplicitConstructorCheckTest, Basic) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3122.2.patch
Type: text/x-patch
Size: 1475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140319/51db06c5/attachment.bin>


More information about the cfe-commits mailing list