[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

llvm-svn: 298101
This commit is contained in:
Alexander Kornienko 2017-03-17 16:40:34 +00:00
parent f98dec1c53
commit b10daaf198
2 changed files with 14 additions and 0 deletions

View File

@ -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")

View File

@ -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;
};