@@ -145,21 +145,23 @@ mergeIntoInferredVersion(const std::optional<llvm::VersionTuple> &Version,
145
145
// / Merge an attribute's availability with an existing inferred availability
146
146
// / so that the new inferred availability is at least as available as
147
147
// / the attribute requires.
148
- static void mergeWithInferredAvailability (const AvailableAttr * Attr,
148
+ static void mergeWithInferredAvailability (SemanticAvailableAttr Attr,
149
149
InferredAvailability &Inferred) {
150
- Inferred. PlatformAgnostic
151
- = static_cast <PlatformAgnosticAvailabilityKind>(
150
+ auto *ParsedAttr = Attr. getParsedAttr ();
151
+ Inferred. PlatformAgnostic = static_cast <PlatformAgnosticAvailabilityKind>(
152
152
std::max (static_cast <unsigned >(Inferred.PlatformAgnostic ),
153
- static_cast <unsigned >(Attr->getPlatformAgnosticAvailability ())));
153
+ static_cast <unsigned >(
154
+ ParsedAttr->getPlatformAgnosticAvailability ())));
154
155
155
156
// The merge of two introduction versions is the maximum of the two versions.
156
- if (mergeIntoInferredVersion (Attr->Introduced , Inferred.Introduced , std::max)) {
157
- Inferred.IsSPI = Attr->isSPI ();
157
+ if (mergeIntoInferredVersion (Attr.getIntroduced (), Inferred.Introduced ,
158
+ std::max)) {
159
+ Inferred.IsSPI = ParsedAttr->isSPI ();
158
160
}
159
161
160
162
// The merge of deprecated and obsoleted versions takes the minimum.
161
- mergeIntoInferredVersion (Attr-> Deprecated , Inferred.Deprecated , std::min);
162
- mergeIntoInferredVersion (Attr-> Obsoleted , Inferred.Obsoleted , std::min);
163
+ mergeIntoInferredVersion (Attr. getDeprecated () , Inferred.Deprecated , std::min);
164
+ mergeIntoInferredVersion (Attr. getObsoleted () , Inferred.Obsoleted , std::min);
163
165
}
164
166
165
167
// / Create an implicit availability attribute for the given platform
@@ -204,36 +206,34 @@ void AvailabilityInference::applyInferredAvailableAttrs(
204
206
205
207
// Iterate over the declarations and infer required availability on
206
208
// a per-platform basis.
209
+ // FIXME: [availability] Generalize to AvailabilityDomain.
207
210
std::map<PlatformKind, InferredAvailability> Inferred;
208
211
for (const Decl *D : InferredFromDecls) {
209
- llvm::SmallVector<const AvailableAttr * , 8 > MergedAttrs;
212
+ llvm::SmallVector<SemanticAvailableAttr , 8 > MergedAttrs;
210
213
211
214
do {
212
- llvm::SmallVector<const AvailableAttr *, 8 > PendingAttrs;
213
-
214
- for (const DeclAttribute *Attr : D->getAttrs ()) {
215
- auto *AvAttr = dyn_cast<AvailableAttr>(Attr);
216
- if (!AvAttr || AvAttr->isInvalid ())
217
- continue ;
215
+ llvm::SmallVector<SemanticAvailableAttr, 8 > PendingAttrs;
218
216
217
+ for (auto AvAttr :
218
+ D->getSemanticAvailableAttrs ()) {
219
219
// Skip an attribute from an outer declaration if it is for a platform
220
220
// that was already handled implicitly by an attribute from an inner
221
221
// declaration.
222
- if (llvm::any_of (
223
- MergedAttrs, [&AvAttr](const AvailableAttr * MergedAttr) {
224
- return inheritsAvailabilityFromPlatform (
225
- AvAttr-> getPlatform (), MergedAttr-> getPlatform ());
226
- }))
222
+ if (llvm::any_of (MergedAttrs,
223
+ [&AvAttr](SemanticAvailableAttr MergedAttr) {
224
+ return inheritsAvailabilityFromPlatform (
225
+ AvAttr. getPlatform (), MergedAttr. getPlatform ());
226
+ }))
227
227
continue ;
228
228
229
- mergeWithInferredAvailability (AvAttr, Inferred[AvAttr-> getPlatform ()]);
229
+ mergeWithInferredAvailability (AvAttr, Inferred[AvAttr. getPlatform ()]);
230
230
PendingAttrs.push_back (AvAttr);
231
231
232
- if (Message.empty () && !AvAttr-> Message .empty ())
233
- Message = AvAttr-> Message ;
232
+ if (Message.empty () && !AvAttr. getMessage () .empty ())
233
+ Message = AvAttr. getMessage () ;
234
234
235
- if (Rename.empty () && !AvAttr-> Rename .empty ())
236
- Rename = AvAttr-> Rename ;
235
+ if (Rename.empty () && !AvAttr. getRename () .empty ())
236
+ Rename = AvAttr. getRename () ;
237
237
}
238
238
239
239
MergedAttrs.append (PendingAttrs);
0 commit comments