@@ -100,7 +100,7 @@ class AvailabilityDomain final {
100
100
using InlineDomainPtr =
101
101
llvm::PointerEmbeddedInt<uint32_t , InlineDomain::ReprBits>;
102
102
using Storage =
103
- llvm::PointerUnion<CustomAvailabilityDomain *, InlineDomainPtr>;
103
+ llvm::PointerUnion<const CustomAvailabilityDomain *, InlineDomainPtr>;
104
104
Storage storage;
105
105
106
106
AvailabilityDomain (Kind kind)
@@ -111,7 +111,8 @@ class AvailabilityDomain final {
111
111
AvailabilityDomain (PlatformKind platform)
112
112
: storage(InlineDomain(Kind::Platform, platform).asInteger()) {};
113
113
114
- AvailabilityDomain (CustomAvailabilityDomain *domain) : storage(domain) {};
114
+ AvailabilityDomain (const CustomAvailabilityDomain *domain)
115
+ : storage(domain) {};
115
116
116
117
AvailabilityDomain (Storage storage) : storage(storage) {};
117
118
@@ -122,9 +123,9 @@ class AvailabilityDomain final {
122
123
: std::nullopt;
123
124
}
124
125
125
- CustomAvailabilityDomain *getCustomDomain () const {
126
+ const CustomAvailabilityDomain *getCustomDomain () const {
126
127
ASSERT (isCustom ());
127
- return storage.get <CustomAvailabilityDomain *>();
128
+ return storage.get <const CustomAvailabilityDomain *>();
128
129
}
129
130
130
131
public:
@@ -152,7 +153,7 @@ class AvailabilityDomain final {
152
153
return AvailabilityDomain (Kind::Embedded);
153
154
}
154
155
155
- static AvailabilityDomain forCustom (CustomAvailabilityDomain *domain) {
156
+ static AvailabilityDomain forCustom (const CustomAvailabilityDomain *domain) {
156
157
return AvailabilityDomain (domain);
157
158
}
158
159
@@ -294,7 +295,7 @@ struct StableAvailabilityDomainComparator {
294
295
};
295
296
296
297
// / Represents an availability domain that has been defined in a module.
297
- class CustomAvailabilityDomain : public ASTAllocated <CustomAvailabilityDomain> {
298
+ class CustomAvailabilityDomain : public llvm ::FoldingSetNode {
298
299
public:
299
300
enum class Kind {
300
301
// / A domain that is known to be enabled at compile time.
@@ -313,12 +314,20 @@ class CustomAvailabilityDomain : public ASTAllocated<CustomAvailabilityDomain> {
313
314
CustomAvailabilityDomain (Identifier name, ModuleDecl *mod, Kind kind);
314
315
315
316
public:
316
- static CustomAvailabilityDomain *create ( const ASTContext &ctx, StringRef name ,
317
- ModuleDecl *mod, Kind kind);
317
+ static const CustomAvailabilityDomain *get (StringRef name, ModuleDecl *mod ,
318
+ Kind kind, const ASTContext &ctx );
318
319
319
320
Identifier getName () const { return name; }
320
321
Kind getKind () const { return kind; }
321
322
ModuleDecl *getModule () const { return mod; }
323
+
324
+ // / Uniquing for `ASTContext`.
325
+ static void Profile (llvm::FoldingSetNodeID &ID, Identifier name,
326
+ ModuleDecl *mod, Kind kind);
327
+
328
+ void Profile (llvm::FoldingSetNodeID &ID) const {
329
+ Profile (ID, name, mod, kind);
330
+ }
322
331
};
323
332
324
333
// / Represents either a resolved availability domain or an identifier written
0 commit comments