[clang-tools-extra] r207534 - Fix the message for "Move constructor declared explicit".

Alexander Kornienko alexfh at google.com
Tue Apr 29 08:50:14 PDT 2014


Author: alexfh
Date: Tue Apr 29 10:50:14 2014
New Revision: 207534

URL: http://llvm.org/viewvc/llvm-project?rev=207534&view=rev
Log:
Fix the message for "Move constructor declared explicit".
Make the tests for removal of 'explicit' more diverse.

Modified:
    clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
    clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp?rev=207534&r1=207533&r2=207534&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp Tue Apr 29 10:50:14 2014
@@ -71,7 +71,8 @@ void ExplicitConstructorCheck::check(con
                   Ctor->getOuterLocStart(), Ctor->getLocEnd(), isKWExplicit);
     if (ExplicitTokenRange.isValid()) {
       DiagnosticBuilder Diag = diag(ExplicitTokenRange.getBegin(),
-                                    "Copy constructor declared explicit.");
+                                    "%0 constructor declared explicit.")
+                               << (Ctor->isMoveConstructor() ? "Move" : "Copy");
       Diag << FixItHint::CreateRemoval(
           CharSourceRange::getCharRange(ExplicitTokenRange));
     }

Modified: clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp?rev=207534&r1=207533&r2=207534&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp Tue Apr 29 10:50:14 2014
@@ -39,12 +39,12 @@ TEST(ExplicitConstructorCheckTest, OutOf
 
 TEST(ExplicitConstructorCheckTest, RemoveExplicit) {
   EXPECT_EQ("class A { A(const A&); };\n"
-            "class B { /*asdf*/  B(const B&); };\n"
-            "class C { /*asdf*/  C(const C&); };",
+            "class B { /*asdf*/  B(B&&); };\n"
+            "class C { /*asdf*/  C(const C&, int i = 0); };",
             runCheckOnCode<ExplicitConstructorCheck>(
                 "class A { explicit    A(const A&); };\n"
-                "class B { explicit   /*asdf*/  B(const B&); };\n"
-                "class C { explicit/*asdf*/  C(const C&); };"));
+                "class B { explicit   /*asdf*/  B(B&&); };\n"
+                "class C { explicit/*asdf*/  C(const C&, int i = 0); };"));
 }
 
 } // namespace test





More information about the cfe-commits mailing list