Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / Host / macosx / cfcpp / CFCMutableSet.cpp
blobda2ef6c8c998a0e6a90339a233c6df7470acb9f0
1 //===-- CFCMutableSet.cpp -------------------------------------------------===//
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 #include "CFCMutableSet.h"
12 // CFCString constructor
13 CFCMutableSet::CFCMutableSet(CFMutableSetRef s)
14 : CFCReleaser<CFMutableSetRef>(s) {}
16 // CFCMutableSet copy constructor
17 CFCMutableSet::CFCMutableSet(const CFCMutableSet &rhs) = default;
19 // CFCMutableSet copy constructor
20 const CFCMutableSet &CFCMutableSet::operator=(const CFCMutableSet &rhs) {
21 if (this != &rhs)
22 *this = rhs;
23 return *this;
26 // Destructor
27 CFCMutableSet::~CFCMutableSet() = default;
29 CFIndex CFCMutableSet::GetCount() const {
30 CFMutableSetRef set = get();
31 if (set)
32 return ::CFSetGetCount(set);
33 return 0;
36 CFIndex CFCMutableSet::GetCountOfValue(const void *value) const {
37 CFMutableSetRef set = get();
38 if (set)
39 return ::CFSetGetCountOfValue(set, value);
40 return 0;
43 const void *CFCMutableSet::GetValue(const void *value) const {
44 CFMutableSetRef set = get();
45 if (set)
46 return ::CFSetGetValue(set, value);
47 return NULL;
50 const void *CFCMutableSet::AddValue(const void *value, bool can_create) {
51 CFMutableSetRef set = get();
52 if (set == NULL) {
53 if (!can_create)
54 return NULL;
55 set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks);
56 reset(set);
58 if (set != NULL) {
59 ::CFSetAddValue(set, value);
60 return value;
62 return NULL;
65 void CFCMutableSet::RemoveValue(const void *value) {
66 CFMutableSetRef set = get();
67 if (set)
68 ::CFSetRemoveValue(set, value);
71 void CFCMutableSet::RemoveAllValues() {
72 CFMutableSetRef set = get();
73 if (set)
74 ::CFSetRemoveAllValues(set);