[LoongArch] Fix the assertion for atomic store with 'ptr' type
[llvm-project.git] / llvm / unittests / ADT / CountCopyAndMove.h
blob126054427b81a35ee70a610370376e730ff7d82a
1 //===- llvm/unittest/ADT/CountCopyAndMove.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_COUNTCOPYANDMOVE_H
10 #define LLVM_UNITTESTS_ADT_COUNTCOPYANDMOVE_H
12 namespace llvm {
14 struct CountCopyAndMove {
15 static int CopyConstructions;
16 static int CopyAssignments;
17 static int MoveConstructions;
18 static int MoveAssignments;
19 static int Destructions;
20 int val;
22 CountCopyAndMove() = default;
23 explicit CountCopyAndMove(int val) : val(val) {}
24 CountCopyAndMove(const CountCopyAndMove &other) : val(other.val) {
25 ++CopyConstructions;
27 CountCopyAndMove &operator=(const CountCopyAndMove &other) {
28 val = other.val;
29 ++CopyAssignments;
30 return *this;
32 CountCopyAndMove(CountCopyAndMove &&other) : val(other.val) {
33 ++MoveConstructions;
35 CountCopyAndMove &operator=(CountCopyAndMove &&other) {
36 val = other.val;
37 ++MoveAssignments;
38 return *this;
40 ~CountCopyAndMove() { ++Destructions; }
42 static void ResetCounts() {
43 CopyConstructions = 0;
44 CopyAssignments = 0;
45 MoveConstructions = 0;
46 MoveAssignments = 0;
47 Destructions = 0;
50 static int TotalCopies() { return CopyConstructions + CopyAssignments; }
52 static int TotalMoves() { return MoveConstructions + MoveAssignments; }
55 } // end namespace llvm
57 #endif // LLVM_UNITTESTS_ADT_COUNTCOPYANDMOVE_H