[clang-tools-extra] r238202 - [clang-tidy] misc-noexcept-move-ctors should ignore implicit constructors and assignments.
Alexander Kornienko
alexfh at google.com
Tue May 26 07:35:09 PDT 2015
Author: alexfh
Date: Tue May 26 09:35:09 2015
New Revision: 238202
URL: http://llvm.org/viewvc/llvm-project?rev=238202&view=rev
Log:
[clang-tidy] misc-noexcept-move-ctors should ignore implicit constructors and assignments.
Modified:
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/NoexceptMoveCtorsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp?rev=238202&r1=238201&r2=238202&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.cpp Tue May 26 09:35:09 2015
@@ -18,7 +18,8 @@ namespace tidy {
void NoexceptMoveCtorsCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
- methodDecl(anyOf(constructorDecl(), hasOverloadedOperatorName("=")))
+ methodDecl(anyOf(constructorDecl(), hasOverloadedOperatorName("=")),
+ unless(isImplicit()), unless(isDeleted()))
.bind("decl"),
this);
}
Modified: 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=238202&r1=238201&r2=238202&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveCtorsCheck.h Tue May 26 09:35:09 2015
@@ -15,9 +15,9 @@
namespace clang {
namespace tidy {
-/// \brief The check flags 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).
+/// \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
Modified: 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=238202&r1=238201&r2=238202&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-ctors.cpp Tue May 26 09:35:09 2015
@@ -14,6 +14,13 @@ struct B {
// 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();
@@ -34,4 +41,5 @@ public:
struct OK3 {
OK3(OK3 &&) noexcept(false) {}
+ OK3 &operator=(OK3 &&) = delete;
};
More information about the cfe-commits
mailing list