|
20 | 20 | #include "swift/Basic/TypeID.h"
|
21 | 21 | #include "llvm/ADT/DenseMapInfo.h"
|
22 | 22 | #include "llvm/ADT/Hashing.h"
|
| 23 | +#include "llvm/ADT/IntrusiveRefCntPtr.h" |
23 | 24 | #include <string>
|
24 | 25 |
|
25 | 26 | namespace llvm {
|
@@ -50,7 +51,7 @@ class DiagnosticEngine;
|
50 | 51 | ///
|
51 | 52 | class AnyRequest {
|
52 | 53 | /// Abstract base class used to hold the specific request kind.
|
53 |
| - class HolderBase { |
| 54 | + class HolderBase : public llvm::RefCountedBase<HolderBase> { |
54 | 55 | public:
|
55 | 56 | /// The type ID of the request being stored.
|
56 | 57 | const uint64_t typeID;
|
@@ -128,7 +129,7 @@ class AnyRequest {
|
128 | 129 | } storageKind = StorageKind::Normal;
|
129 | 130 |
|
130 | 131 | /// The data stored in this value.
|
131 |
| - std::shared_ptr<HolderBase> stored; |
| 132 | + llvm::IntrusiveRefCntPtr<HolderBase> stored; |
132 | 133 |
|
133 | 134 | AnyRequest(StorageKind storageKind) : storageKind(storageKind) {
|
134 | 135 | assert(storageKind != StorageKind::Normal);
|
@@ -161,8 +162,9 @@ class AnyRequest {
|
161 | 162 | template<typename T>
|
162 | 163 | AnyRequest(T&& value) : storageKind(StorageKind::Normal) {
|
163 | 164 | using ValueType =
|
164 |
| - typename std::remove_cv<typename std::remove_reference<T>::type>::type; |
165 |
| - stored.reset(new Holder<ValueType>(std::forward<T>(value))); |
| 165 | + typename std::remove_cv<typename std::remove_reference<T>::type>::type; |
| 166 | + stored = llvm::IntrusiveRefCntPtr<HolderBase>( |
| 167 | + new Holder<ValueType>(std::forward<T>(value))); |
166 | 168 | }
|
167 | 169 |
|
168 | 170 | /// Cast to a specific (known) type.
|
|
0 commit comments