Debian Codegraph @

clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor-fix.cpp

raw
1 // RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t -- -- -fexceptions
2
3 struct C_1 {
4 ~C_1() {}
5 C_1(int a) {}
6 C_1(C_1&& a) :C_1(5) {}
7 // CHECK-FIXES: ){{.*}}noexcept{{.*}}:
8 C_1& operator=(C_1&&) { return *this; }
9 // CHECK-FIXES: ){{.*}}noexcept{{.*}} {
10 };
11
12 struct C_2 {
13 ~C_2() {}
14 C_2(C_2&& a);
15 // CHECK-FIXES: ){{.*}}noexcept{{.*}};
16 C_2& operator=(C_2&&);
17 // CHECK-FIXES: ){{.*}}noexcept{{.*}};
18 };
19
20 C_2::C_2(C_2&& a) {}
21 // CHECK-FIXES: ){{.*}}noexcept{{.*}} {}
22 C_2& C_2::operator=(C_2&&) { return *this; }
23 // CHECK-FIXES: ){{.*}}noexcept{{.*}} {
24
25 struct C_3 {
26 ~C_3() {}
27 C_3(C_3&& a);
28 // CHECK-FIXES: ){{.*}}noexcept{{.*}};
29 C_3& operator=(C_3&& a);
30 // CHECK-FIXES: ){{.*}}noexcept{{.*}};
31 };
32
33 C_3::C_3(C_3&& a) = default;
34 C_3& C_3::operator=(C_3&& a) = default;
35
36 template <class T>
37 struct C_4 {
38 C_4(C_4<T>&&) {}
39 // CHECK-FIXES: ){{.*}}noexcept{{.*}} {}
40 ~C_4() {}
41 C_4& operator=(C_4&& a) = default;
42 };
43
44 template <class T>
45 struct C_5 {
46 C_5(C_5<T>&&) {}
47 // CHECK-FIXES:){{.*}}noexcept{{.*}} {}
48 ~C_5() {}
49 auto operator=(C_5&& a)->C_5<T> = default;
50 };
51
52 template <class T>
53 struct C_6 {
54 C_6(C_6<T>&&) {}
55 // CHECK-FIXES:){{.*}}noexcept{{.*}} {}
56 ~C_6() {}
57 auto operator=(C_6&& a)->C_6<T>;
58 // CHECK-FIXES:){{.*}}noexcept{{.*}};
59 };
60
61 template <class T>
62 auto C_6<T>::operator=(C_6<T>&& a) -> C_6<T> {}
63 // CHECK-FIXES: ){{.*}}noexcept{{.*}} {}