@@ -109,8 +109,7 @@ namespace {
109
109
// / The inferred availability required to access a group of declarations
110
110
// / on a single platform.
111
111
struct InferredAvailability {
112
- PlatformAgnosticAvailabilityKind PlatformAgnostic
113
- = PlatformAgnosticAvailabilityKind::None;
112
+ AvailableAttr::Kind Kind = AvailableAttr::Kind::Default;
114
113
115
114
std::optional<llvm::VersionTuple> Introduced;
116
115
std::optional<llvm::VersionTuple> Deprecated;
@@ -148,10 +147,9 @@ mergeIntoInferredVersion(const std::optional<llvm::VersionTuple> &Version,
148
147
static void mergeWithInferredAvailability (SemanticAvailableAttr Attr,
149
148
InferredAvailability &Inferred) {
150
149
auto *ParsedAttr = Attr.getParsedAttr ();
151
- Inferred.PlatformAgnostic = static_cast <PlatformAgnosticAvailabilityKind>(
152
- std::max (static_cast <unsigned >(Inferred.PlatformAgnostic ),
153
- static_cast <unsigned >(
154
- ParsedAttr->getPlatformAgnosticAvailability ())));
150
+ Inferred.Kind = static_cast <AvailableAttr::Kind>(
151
+ std::max (static_cast <unsigned >(Inferred.Kind ),
152
+ static_cast <unsigned >(ParsedAttr->getKind ())));
155
153
156
154
// The merge of two introduction versions is the maximum of the two versions.
157
155
if (mergeIntoInferredVersion (Attr.getIntroduced (), Inferred.Introduced ,
@@ -164,19 +162,18 @@ static void mergeWithInferredAvailability(SemanticAvailableAttr Attr,
164
162
mergeIntoInferredVersion (Attr.getObsoleted (), Inferred.Obsoleted , std::min);
165
163
}
166
164
167
- // / Create an implicit availability attribute for the given platform
165
+ // / Create an implicit availability attribute for the given domain
168
166
// / and with the inferred availability.
169
- static AvailableAttr *createAvailableAttr (PlatformKind Platform ,
167
+ static AvailableAttr *createAvailableAttr (AvailabilityDomain Domain ,
170
168
const InferredAvailability &Inferred,
171
- StringRef Message,
172
- StringRef Rename,
169
+ StringRef Message, StringRef Rename,
173
170
ValueDecl *RenameDecl,
174
171
ASTContext &Context) {
175
172
// If there is no information that would go into the availability attribute,
176
173
// don't create one.
177
- if (Inferred.PlatformAgnostic == PlatformAgnosticAvailabilityKind::None &&
178
- !Inferred.Introduced && !Inferred.Deprecated && !Inferred. Obsoleted &&
179
- Message. empty () && Rename.empty () && !RenameDecl)
174
+ if (Inferred.Kind == AvailableAttr::Kind::Default && !Inferred. Introduced &&
175
+ !Inferred.Deprecated && !Inferred.Obsoleted && Message. empty () &&
176
+ Rename.empty () && !RenameDecl)
180
177
return nullptr ;
181
178
182
179
llvm::VersionTuple Introduced =
@@ -186,11 +183,10 @@ static AvailableAttr *createAvailableAttr(PlatformKind Platform,
186
183
llvm::VersionTuple Obsoleted =
187
184
Inferred.Obsoleted .value_or (llvm::VersionTuple ());
188
185
189
- return new (Context)
190
- AvailableAttr (SourceLoc (), SourceRange (), Platform, Message, Rename,
191
- Introduced, SourceRange (), Deprecated, SourceRange (),
192
- Obsoleted, SourceRange (), Inferred.PlatformAgnostic ,
193
- /* Implicit=*/ true , Inferred.IsSPI );
186
+ return new (Context) AvailableAttr (
187
+ SourceLoc (), SourceRange (), Domain, Inferred.Kind , Message, Rename,
188
+ Introduced, SourceRange (), Deprecated, SourceRange (), Obsoleted,
189
+ SourceRange (), /* Implicit=*/ true , Inferred.IsSPI );
194
190
}
195
191
196
192
void AvailabilityInference::applyInferredAvailableAttrs (
@@ -214,8 +210,7 @@ void AvailabilityInference::applyInferredAvailableAttrs(
214
210
do {
215
211
llvm::SmallVector<SemanticAvailableAttr, 8 > PendingAttrs;
216
212
217
- for (auto AvAttr :
218
- D->getSemanticAvailableAttrs ()) {
213
+ for (auto AvAttr : D->getSemanticAvailableAttrs ()) {
219
214
// Skip an attribute from an outer declaration if it is for a platform
220
215
// that was already handled implicitly by an attribute from an inner
221
216
// declaration.
@@ -250,8 +245,12 @@ void AvailabilityInference::applyInferredAvailableAttrs(
250
245
// Create an availability attribute for each observed platform and add
251
246
// to ToDecl.
252
247
for (auto &Pair : Inferred) {
253
- auto *Attr = createAvailableAttr (Pair.first , Pair.second , Message,
254
- Rename, RenameDecl, Context);
248
+ auto Domain = (Pair.first == PlatformKind::none)
249
+ ? AvailabilityDomain::forUniversal ()
250
+ : AvailabilityDomain::forPlatform (Pair.first );
251
+
252
+ auto *Attr = createAvailableAttr (Domain, Pair.second , Message, Rename,
253
+ RenameDecl, Context);
255
254
256
255
if (Attr) {
257
256
if (RenameDecl && ToValueDecl)
0 commit comments