[clang-tools-extra] r238326 - [clang-tidy] Renamed misc-noexcept-move-ctors to misc-noexcept-move-constructor

Alexander Kornienko alexfh at google.com
Wed May 27 07:24:11 PDT 2015


Author: alexfh
Date: Wed May 27 09:24:11 2015
New Revision: 238326

URL: http://llvm.org/viewvc/llvm-project?rev=238326&view=rev
Log:
[clang-tidy] Renamed misc-noexcept-move-ctors to misc-noexcept-move-constructor

Added:
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
      - copied, changed from r238315, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h
      - copied, changed from r238315, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h
    clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
      - copied, changed from r238315, clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp
Removed:
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h
    clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp
Modified:
    clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=238326&r1=238325&r2=238326&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed May 27 09:24:11 2015
@@ -8,7 +8,7 @@ add_clang_library(clangTidyMiscModule
   InaccurateEraseCheck.cpp
   InefficientAlgorithmCheck.cpp
   MiscTidyModule.cpp
-  NoexceptMoveCtorsCheck.cpp
+  NoexceptMoveConstructorCheck.cpp
   StaticAssertCheck.cpp
   SwappedArgumentsCheck.cpp
   UndelegatedConstructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=238326&r1=238325&r2=238326&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Wed May 27 09:24:11 2015
@@ -16,7 +16,7 @@
 #include "BoolPointerImplicitConversionCheck.h"
 #include "InaccurateEraseCheck.h"
 #include "InefficientAlgorithmCheck.h"
-#include "NoexceptMoveCtorsCheck.h"
+#include "NoexceptMoveConstructorCheck.h"
 #include "StaticAssertCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "UndelegatedConstructor.h"
@@ -42,8 +42,8 @@ public:
         "misc-inaccurate-erase");
     CheckFactories.registerCheck<InefficientAlgorithmCheck>(
         "misc-inefficient-algorithm");
-    CheckFactories.registerCheck<NoexceptMoveCtorsCheck>(
-        "misc-noexcept-move-ctors");
+    CheckFactories.registerCheck<NoexceptMoveConstructorCheck>(
+        "misc-noexcept-move-constructor");
     CheckFactories.registerCheck<StaticAssertCheck>(
         "misc-static-assert");
     CheckFactories.registerCheck<SwappedArgumentsCheck>(

Copied: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp (from r238315, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp&p1=clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp&r1=238315&r2=238326&rev=238326&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp Wed May 27 09:24:11 2015
@@ -1,4 +1,4 @@
-//===--- NoexceptMoveCtorsCheck.cpp - clang-tidy---------------------------===//
+//===--- NoexceptMoveConstructorCheck.cpp - clang-tidy---------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "NoexceptMoveCtorsCheck.h"
+#include "NoexceptMoveConstructorCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
 namespace clang {
 namespace tidy {
 
-void NoexceptMoveCtorsCheck::registerMatchers(MatchFinder *Finder) {
+void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
       methodDecl(anyOf(constructorDecl(), hasOverloadedOperatorName("=")),
                  unless(isImplicit()), unless(isDeleted()))
@@ -24,7 +24,8 @@ void NoexceptMoveCtorsCheck::registerMat
       this);
 }
 
-void NoexceptMoveCtorsCheck::check(const MatchFinder::MatchResult &Result) {
+void NoexceptMoveConstructorCheck::check(
+    const MatchFinder::MatchResult &Result) {
   if (const auto *Decl = Result.Nodes.getNodeAs<CXXMethodDecl>("decl")) {
     StringRef MethodType = "assignment operator";
     if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(Decl)) {

Copied: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h (from r238315, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h?p2=clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h&p1=clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h&r1=238315&r2=238326&rev=238326&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h Wed May 27 09:24:11 2015
@@ -1,4 +1,4 @@
-//===--- NoexceptMoveCtorsCheck.h - clang-tidy-------------------*- C++ -*-===//
+//===--- NoexceptMoveConstructorCheck.h - clang-tidy-------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
 
 #include "../ClangTidy.h"
 
@@ -22,9 +22,9 @@ namespace tidy {
 /// Move constructors of all the types used with STL containers, for example,
 /// need to be declared \c noexcept. Otherwise STL will choose copy constructors
 /// instead. The same is valid for move assignment operations.
-class NoexceptMoveCtorsCheck : public ClangTidyCheck {
+class NoexceptMoveConstructorCheck : public ClangTidyCheck {
 public:
-  NoexceptMoveCtorsCheck(StringRef Name, ClangTidyContext *Context)
+  NoexceptMoveConstructorCheck(StringRef Name, ClangTidyContext *Context)
       : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
@@ -33,5 +33,5 @@ public:
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
 

Removed: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp?rev=238325&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp (removed)
@@ -1,66 +0,0 @@
-//===--- NoexceptMoveCtorsCheck.cpp - clang-tidy---------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "NoexceptMoveCtorsCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-
-void NoexceptMoveCtorsCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-      methodDecl(anyOf(constructorDecl(), hasOverloadedOperatorName("=")),
-                 unless(isImplicit()), unless(isDeleted()))
-          .bind("decl"),
-      this);
-}
-
-void NoexceptMoveCtorsCheck::check(const MatchFinder::MatchResult &Result) {
-  if (const auto *Decl = Result.Nodes.getNodeAs<CXXMethodDecl>("decl")) {
-    StringRef MethodType = "assignment operator";
-    if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(Decl)) {
-      if (!Ctor->isMoveConstructor())
-        return;
-      MethodType = "constructor";
-    } else if (!Decl->isMoveAssignmentOperator()) {
-      return;
-    }
-
-    const auto *ProtoType = Decl->getType()->getAs<FunctionProtoType>();
-    switch(ProtoType->getNoexceptSpec(*Result.Context)) {
-      case  FunctionProtoType::NR_NoNoexcept:
-        diag(Decl->getLocation(), "move %0s should be marked noexcept")
-            << MethodType;
-        // FIXME: Add a fixit.
-        break;
-      case FunctionProtoType::NR_Throw:
-        // Don't complain about nothrow(false), but complain on nothrow(expr)
-        // where expr evaluates to false.
-        if (const Expr *E = ProtoType->getNoexceptExpr()) {
-          if (isa<CXXBoolLiteralExpr>(E))
-            break;
-          diag(E->getExprLoc(),
-               "noexcept specifier on the move %0 evaluates to 'false'")
-              << MethodType;
-        }
-        break;
-      case FunctionProtoType::NR_Nothrow:
-      case FunctionProtoType::NR_Dependent:
-      case FunctionProtoType::NR_BadNoexcept:
-        break;
-    }
-  }
-}
-
-} // namespace tidy
-} // namespace clang
-

Removed: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h?rev=238325&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h (removed)
@@ -1,37 +0,0 @@
-//===--- NoexceptMoveCtorsCheck.h - clang-tidy-------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-
-/// \brief The check flags user-defined move constructors and assignment
-/// operators not marked with \c noexcept or marked with \c noexcept(expr) where
-/// \c expr evaluates to \c false (but is not a \c false literal itself).
-///
-/// Move constructors of all the types used with STL containers, for example,
-/// need to be declared \c noexcept. Otherwise STL will choose copy constructors
-/// instead. The same is valid for move assignment operations.
-class NoexceptMoveCtorsCheck : public ClangTidyCheck {
-public:
-  NoexceptMoveCtorsCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context) {}
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-};
-
-} // namespace tidy
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPT_MOVE_CTORS_H
-

Copied: clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp (from r238315, clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp&r1=238315&r2=238326&rev=238326&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp Wed May 27 09:24:11 2015
@@ -1,9 +1,9 @@
-// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-noexcept-move-ctors %t
+// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-noexcept-move-constructor %t
 // REQUIRES: shell
 
 class A {
   A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-ctors]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
   A &operator=(A &&);
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
 };
@@ -11,7 +11,7 @@ class A {
 struct B {
   static constexpr bool kFalse = false;
   B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-ctors]
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
 };
 
 class OK {};

Removed: clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp?rev=238325&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-ctors.cpp (removed)
@@ -1,45 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-noexcept-move-ctors %t
-// REQUIRES: shell
-
-class A {
-  A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-ctors]
-  A &operator=(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
-};
-
-struct B {
-  static constexpr bool kFalse = false;
-  B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-ctors]
-};
-
-class OK {};
-
-void f() {
-  OK a;
-  a = OK();
-}
-
-class OK1 {
- public:
-  OK1();
-  OK1(const OK1 &);
-  OK1(OK1&&) noexcept;
-  OK1 &operator=(OK1 &&) noexcept;
-  void f();
-  void g() noexcept;
-};
-
-class OK2 {
-  static constexpr bool kTrue = true;
-
-public:
-  OK2(OK2 &&) noexcept(true) {}
-  OK2 &operator=(OK2 &&) noexcept(kTrue) { return *this; }
-};
-
-struct OK3 {
-  OK3(OK3 &&) noexcept(false) {}
-  OK3 &operator=(OK3 &&) = delete;
-};





More information about the cfe-commits mailing list