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
This commit is contained in:
@@ -37,6 +37,16 @@ TEST(ExplicitConstructorCheckTest, OutOfLineDefinitions) {
|
||||
"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
|
||||
|
||||
Reference in New Issue
Block a user