• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t
2 
3 class A {
4   A(A &&);
5   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [performance-noexcept-move-constructor]
6   A &operator=(A &&);
7   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
8 };
9 
10 struct B {
11   static constexpr bool kFalse = false;
12   B(B &&) noexcept(kFalse);
13   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor]
14 };
15 
16 class OK {};
17 
f()18 void f() {
19   OK a;
20   a = OK();
21 }
22 
23 class OK1 {
24 public:
25   OK1();
26   OK1(const OK1 &);
27   OK1(OK1 &&) noexcept;
28   OK1 &operator=(OK1 &&) noexcept;
29   void f();
30   void g() noexcept;
31 };
32 
33 class OK2 {
34   static constexpr bool kTrue = true;
35 
36 public:
OK2(OK2 &&)37   OK2(OK2 &&) noexcept(true) {}
operator =(OK2 &&)38   OK2 &operator=(OK2 &&) noexcept(kTrue) { return *this; }
39 };
40 
41 struct OK3 {
OK3OK342   OK3(OK3 &&) noexcept(false) {}
43   OK3 &operator=(OK3 &&) = delete;
44 };
45 
46 struct OK4 {
47   OK4(OK4 &&) noexcept = default;
48   OK4 &operator=(OK4 &&) noexcept = default;
49 };
50 
51 struct OK5 {
52   OK5(OK5 &&) noexcept(true) = default;
53   OK5 &operator=(OK5 &&) noexcept(true) = default;
54 };
55