Warn on explicit copy constructors.
Summary:
The Google C++ Style Guide doesn't require copy constructors to be
declared explicit, but some people do this by mistake. Make this check detect
and fix such cases.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D3541
llvm-svn: 207531
diff --git a/clang-tools-extra/unittests/clang-tidy/GoogleModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/GoogleModuleTest.cpp
index b09afe2..3c024b1 100644
--- a/clang-tools-extra/unittests/clang-tidy/GoogleModuleTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/GoogleModuleTest.cpp
@@ -37,6 +37,16 @@
"class C { C(int i); }; C::C(int i) {}"));
}
+TEST(ExplicitConstructorCheckTest, RemoveExplicit) {
+ EXPECT_EQ("class A { A(const A&); };\n"
+ "class B { /*asdf*/ B(const B&); };\n"
+ "class C { /*asdf*/ C(const C&); };",
+ runCheckOnCode<ExplicitConstructorCheck>(
+ "class A { explicit A(const A&); };\n"
+ "class B { explicit /*asdf*/ B(const B&); };\n"
+ "class C { explicit/*asdf*/ C(const C&); };"));
+}
+
} // namespace test
} // namespace tidy
} // namespace clang