[PATCH] clang-tidy explicit constructors check: don't warn on deleted constructors.
Alexander Kornienko
alexfh at google.com
Wed Mar 19 05:46:29 PDT 2014
Hi klimek,
http://llvm-reviews.chandlerc.com/D3116
Files:
clang-tidy/google/GoogleTidyModule.cpp
unittests/clang-tidy/ClangTidyTest.h
unittests/clang-tidy/GoogleModuleTest.cpp
Index: clang-tidy/google/GoogleTidyModule.cpp
===================================================================
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -33,7 +33,8 @@
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;
Index: unittests/clang-tidy/ClangTidyTest.h
===================================================================
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -46,13 +46,14 @@
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;
Index: unittests/clang-tidy/GoogleModuleTest.cpp
===================================================================
--- unittests/clang-tidy/GoogleModuleTest.cpp
+++ unittests/clang-tidy/GoogleModuleTest.cpp
@@ -12,6 +12,8 @@
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3116.1.patch
Type: text/x-patch
Size: 2216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140319/e53ad614/attachment.bin>
More information about the cfe-commits
mailing list