diff options
author | Alexander Kornienko <alexfh@google.com> | 2017-11-28 16:41:03 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2017-11-28 16:41:03 +0000 |
commit | 1bfcba8ceaf3c8dc9b2443e61b8649c3506ca2f0 (patch) | |
tree | ac2883c5617a84a282e431ec048900ff39a7178d /clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp | |
parent | 14230e02ffe1a42b509360d8d8b687ebc961a75e (diff) | |
download | bcm5719-llvm-1bfcba8ceaf3c8dc9b2443e61b8649c3506ca2f0.tar.gz bcm5719-llvm-1bfcba8ceaf3c8dc9b2443e61b8649c3506ca2f0.zip |
[clang-tidy] Move more checks from misc- to performance-
Summary:
rename_check.py misc-move-const-arg performance-move-const-arg
rename_check.py misc-noexcept-move-constructor performance-noexcept-move-constructor
Reviewers: hokein, xazax.hun
Reviewed By: xazax.hun
Subscribers: rnkovacs, klimek, mgorny, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D40507
llvm-svn: 319183
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp b/clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp new file mode 100644 index 00000000000..70d70650c1d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp @@ -0,0 +1,54 @@ +// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t + +class A { + A(A &&); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [performance-noexcept-move-constructor] + 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' [performance-noexcept-move-constructor] +}; + +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; +}; + +struct OK4 { + OK4(OK4 &&) noexcept = default; + OK4 &operator=(OK4 &&) noexcept = default; +}; + +struct OK5 { + OK5(OK5 &&) noexcept(true) = default; + OK5 &operator=(OK5 &&) noexcept(true) = default; +}; |