[clang-tools-extra] r298101 - [Clang-tidy] Fix for misc-noexcept-move-constructor false triggers on defaulted declarations

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 17 09:40:35 PDT 2017


Author: alexfh
Date: Fri Mar 17 11:40:34 2017
New Revision: 298101

URL: http://llvm.org/viewvc/llvm-project?rev=298101&view=rev
Log:
[Clang-tidy] Fix for misc-noexcept-move-constructor false triggers on defaulted declarations

Summary:
There is no need for triggering warning when noexcept specifier in move constructor or move-assignment operator is neither evaluated nor uninstantiated.

This fixes bug reported here: bugs.llvm.org/show_bug.cgi?id=24712

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JonasToth, JDevlieghere, cfe-commits

Tags: #clang-tools-extra

Patch by Marek Jenda!

Differential Revision: https://reviews.llvm.org/D31049

Modified:
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp?rev=298101&r1=298100&r2=298101&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp Fri Mar 17 11:40:34 2017
@@ -43,6 +43,10 @@ void NoexceptMoveConstructorCheck::check
     }
 
     const auto *ProtoType = Decl->getType()->getAs<FunctionProtoType>();
+
+    if (isUnresolvedExceptionSpec(ProtoType->getExceptionSpecType()))
+      return;
+
     switch (ProtoType->getNoexceptSpec(*Result.Context)) {
       case FunctionProtoType::NR_NoNoexcept:
         diag(Decl->getLocation(), "move %0s should be marked noexcept")

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp?rev=298101&r1=298100&r2=298101&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp Fri Mar 17 11:40:34 2017
@@ -42,3 +42,13 @@ struct OK3 {
   OK3(OK3 &&) noexcept(false) {}
   OK3 &operator=(OK3 &&) = delete;
 };
+
+struct OK4 {
+  OK4(OK4 &&) noexcept = default;
+  OK4 &operator=(OK4 &&) noexcept = default;
+};
+
+struct OK5 {
+  OK5(OK5 &&) noexcept(true) = default;
+  OK5 &operator=(OK5 &&) noexcept(true) = default;
+};




More information about the cfe-commits mailing list