[clang-tools-extra] r204226 - clang-tidy explicit constructors check: don't warn on deleted constructors.

Alexander Kornienko alexfh at google.com
Wed Mar 19 05:48:22 PDT 2014


Author: alexfh
Date: Wed Mar 19 07:48:22 2014
New Revision: 204226

URL: http://llvm.org/viewvc/llvm-project?rev=204226&view=rev
Log:
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

Modified:
    clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
    clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
    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=204226&r1=204225&r2=204226&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp Wed Mar 19 07:48:22 2014
@@ -33,7 +33,8 @@ void ExplicitConstructorCheck::check(con
       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;

Modified: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h?rev=204226&r1=204225&r2=204226&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h Wed Mar 19 07:48:22 2014
@@ -46,13 +46,14 @@ template <typename T> std::string runChe
   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;

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=204226&r1=204225&r2=204226&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp Wed Mar 19 07:48:22 2014
@@ -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) {





More information about the cfe-commits mailing list