forked from OSchip/llvm-project
clang-tidy explicit constructors check: don't warn on deleted constructors.
Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3116 llvm-svn: 204226
This commit is contained in:
parent
2ea796e05f
commit
f9a7b46ec6
|
@ -33,7 +33,8 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
|
||||
// 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())
|
||||
if (Ctor->isOutOfLine() || Ctor->isExplicit() || Ctor->isImplicit() ||
|
||||
Ctor->isDeleted())
|
||||
return;
|
||||
if (Ctor->getNumParams() == 0 || Ctor->getMinRequiredArguments() > 1)
|
||||
return;
|
||||
|
|
|
@ -46,13 +46,14 @@ template <typename T> std::string runCheckOnCode(StringRef Code) {
|
|||
ClangTidyDiagnosticConsumer DiagConsumer(Context);
|
||||
Check.setContext(&Context);
|
||||
|
||||
if (!tooling::runToolOnCode(new TestPPAction(Check, &Context), Code))
|
||||
if (!tooling::runToolOnCodeWithArgs(new TestPPAction(Check, &Context), Code,
|
||||
{"-std=c++11"}))
|
||||
return "";
|
||||
ast_matchers::MatchFinder Finder;
|
||||
Check.registerMatchers(&Finder);
|
||||
std::unique_ptr<tooling::FrontendActionFactory> Factory(
|
||||
tooling::newFrontendActionFactory(&Finder));
|
||||
if (!tooling::runToolOnCode(Factory->create(), Code))
|
||||
if (!tooling::runToolOnCodeWithArgs(Factory->create(), Code, {"-std=c++11"}))
|
||||
return "";
|
||||
DiagConsumer.finish();
|
||||
tooling::Replacements Fixes;
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace test {
|
|||
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&) = delete; };");
|
||||
}
|
||||
|
||||
TEST(ExplicitConstructorCheckTest, Basic) {
|
||||
|
|
Loading…
Reference in New Issue