@@ -265,13 +265,12 @@ SourceLoc AvailabilityScope::getIntroductionLoc() const {
265
265
llvm_unreachable (" Unhandled Reason in switch." );
266
266
}
267
267
268
- static SourceRange
269
- getAvailabilityConditionVersionSourceRange (const PoundAvailableInfo *PAI,
270
- PlatformKind Platform,
271
- const llvm::VersionTuple &Version) {
268
+ static SourceRange getAvailabilityConditionVersionSourceRange (
269
+ const PoundAvailableInfo *PAI, const DeclContext *ReferenceDC,
270
+ AvailabilityDomain Domain, const llvm::VersionTuple &Version) {
272
271
SourceRange Range;
273
272
for (auto *Spec : PAI->getQueries ()) {
274
- if (Spec->getPlatform () == Platform && Spec->getVersion () == Version) {
273
+ if (Spec->getDomain () == Domain && Spec->getVersion () == Version) {
275
274
// More than one: return invalid range, no unique choice.
276
275
if (Range.isValid ())
277
276
return SourceRange ();
@@ -283,13 +282,14 @@ getAvailabilityConditionVersionSourceRange(const PoundAvailableInfo *PAI,
283
282
}
284
283
285
284
static SourceRange getAvailabilityConditionVersionSourceRange (
286
- const MutableArrayRef<StmtConditionElement> &Conds, PlatformKind Platform,
285
+ const MutableArrayRef<StmtConditionElement> &Conds,
286
+ const DeclContext *ReferenceDC, AvailabilityDomain Domain,
287
287
const llvm::VersionTuple &Version) {
288
288
SourceRange Range;
289
289
for (auto const &C : Conds) {
290
290
if (C.getKind () == StmtConditionElement::CK_Availability) {
291
291
SourceRange R = getAvailabilityConditionVersionSourceRange (
292
- C.getAvailability (), Platform , Version);
292
+ C.getAvailability (), ReferenceDC, Domain , Version);
293
293
// More than one: return invalid range.
294
294
if (Range.isValid ())
295
295
return SourceRange ();
@@ -301,13 +301,13 @@ static SourceRange getAvailabilityConditionVersionSourceRange(
301
301
}
302
302
303
303
static SourceRange
304
- getAvailabilityConditionVersionSourceRange (const Decl *D, PlatformKind Platform,
304
+ getAvailabilityConditionVersionSourceRange (const Decl *D,
305
+ AvailabilityDomain Domain,
305
306
const llvm::VersionTuple &Version) {
306
307
SourceRange Range;
307
308
for (auto Attr : D->getSemanticAvailableAttrs ()) {
308
309
if (Attr.getIntroduced ().has_value () &&
309
- Attr.getIntroduced ().value () == Version &&
310
- Attr.getPlatform () == Platform) {
310
+ Attr.getIntroduced ().value () == Version && Attr.getDomain () == Domain) {
311
311
312
312
// More than one: return invalid range.
313
313
if (Range.isValid ())
@@ -320,29 +320,31 @@ getAvailabilityConditionVersionSourceRange(const Decl *D, PlatformKind Platform,
320
320
}
321
321
322
322
SourceRange AvailabilityScope::getAvailabilityConditionVersionSourceRange (
323
- PlatformKind Platform , const llvm::VersionTuple &Version) const {
323
+ AvailabilityDomain Domain , const llvm::VersionTuple &Version) const {
324
324
switch (getReason ()) {
325
325
case Reason::Decl:
326
326
return ::getAvailabilityConditionVersionSourceRange (Node.getAsDecl (),
327
- Platform , Version);
327
+ Domain , Version);
328
328
329
329
case Reason::IfStmtThenBranch:
330
330
case Reason::IfStmtElseBranch:
331
331
return ::getAvailabilityConditionVersionSourceRange (
332
- Node.getAsIfStmt ()->getCond (), Platform , Version);
332
+ Node.getAsIfStmt ()->getCond (), Node. getDeclContext (), Domain , Version);
333
333
334
334
case Reason::ConditionFollowingAvailabilityQuery:
335
335
return ::getAvailabilityConditionVersionSourceRange (
336
- Node.getAsPoundAvailableInfo (), Platform , Version);
336
+ Node.getAsPoundAvailableInfo (), Node. getDeclContext (), Domain , Version);
337
337
338
338
case Reason::GuardStmtFallthrough:
339
339
case Reason::GuardStmtElseBranch:
340
340
return ::getAvailabilityConditionVersionSourceRange (
341
- Node.getAsGuardStmt ()->getCond (), Platform, Version);
341
+ Node.getAsGuardStmt ()->getCond (), Node.getDeclContext (), Domain,
342
+ Version);
342
343
343
344
case Reason::WhileStmtBody:
344
345
return ::getAvailabilityConditionVersionSourceRange (
345
- Node.getAsWhileStmt ()->getCond (), Platform, Version);
346
+ Node.getAsWhileStmt ()->getCond (), Node.getDeclContext (), Domain,
347
+ Version);
346
348
347
349
case Reason::Root:
348
350
case Reason::DeclImplicit:
0 commit comments