Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / unittests / ADT / MoveOnly.h
blobad64deae771ba2cf239316fc89491fd63062b5ba
1 //===- llvm/unittest/ADT/MoveOnly.h - Optional unit tests -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_UNITTESTS_ADT_MOVEONLY_H
10 #define LLVM_UNITTESTS_ADT_MOVEONLY_H
12 namespace llvm {
14 struct MoveOnly {
15 static unsigned MoveConstructions;
16 static unsigned Destructions;
17 static unsigned MoveAssignments;
18 int val;
19 explicit MoveOnly(int val) : val(val) {
21 MoveOnly(MoveOnly&& other) {
22 val = other.val;
23 ++MoveConstructions;
25 MoveOnly &operator=(MoveOnly&& other) {
26 val = other.val;
27 ++MoveAssignments;
28 return *this;
30 ~MoveOnly() {
31 ++Destructions;
33 static void ResetCounts() {
34 MoveConstructions = 0;
35 Destructions = 0;
36 MoveAssignments = 0;
40 } // end namespace llvm
42 #endif // LLVM_UNITTESTS_ADT_MOVEONLY_H