summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2015-05-27 14:24:11 +0000
committerAlexander Kornienko <alexfh@google.com>2015-05-27 14:24:11 +0000
commit7ed89bcd3bfc772bc071f7bb7964242ba34de5b2 (patch)
treefe203b23419714b8cae6576c18e92b00a4cf4019 /clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp
parent888830adfe82f0ddb2704573cb575bd881748901 (diff)
downloadbcm5719-llvm-7ed89bcd3bfc772bc071f7bb7964242ba34de5b2.tar.gz
bcm5719-llvm-7ed89bcd3bfc772bc071f7bb7964242ba34de5b2.zip
[clang-tidy] Renamed misc-noexcept-move-ctors to misc-noexcept-move-constructor
llvm-svn: 238326
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp b/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp
new file mode 100644
index 00000000000..531138681b4
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp
@@ -0,0 +1,45 @@
+// 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-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' [misc-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;
+};
OpenPOWER on IntegriCloud