@@ -46,6 +46,7 @@ bool AvailabilityContext::PlatformInfo::constrainWith(
4646 CONSTRAIN_BOOL (IsUnavailableInEmbedded, other.IsUnavailableInEmbedded );
4747 }
4848 isConstrained |= CONSTRAIN_BOOL (IsDeprecated, other.IsDeprecated );
49+ isConstrained |= CONSTRAIN_BOOL (AllowsUnsafe, other.AllowsUnsafe );
4950
5051 return isConstrained;
5152}
@@ -63,6 +64,7 @@ bool AvailabilityContext::PlatformInfo::constrainWith(const Decl *decl) {
6364 }
6465
6566 isConstrained |= CONSTRAIN_BOOL (IsDeprecated, decl->isDeprecated ());
67+ isConstrained |= CONSTRAIN_BOOL (AllowsUnsafe, decl->allowsUnsafe ());
6668
6769 return isConstrained;
6870}
@@ -128,7 +130,8 @@ AvailabilityContext::forPlatformRange(const AvailabilityRange &range,
128130 PlatformInfo platformInfo{range, PlatformKind::none,
129131 /* IsUnavailable*/ false ,
130132 /* IsUnavailableInEmbedded*/ false ,
131- /* IsDeprecated*/ false };
133+ /* IsDeprecated*/ false ,
134+ /* AllowsUnsafe*/ false };
132135 return AvailabilityContext (Storage::get (platformInfo, ctx));
133136}
134137
@@ -151,7 +154,8 @@ AvailabilityContext::get(const AvailabilityRange &platformAvailability,
151154 ? *unavailablePlatform
152155 : PlatformKind::none,
153156 unavailablePlatform.has_value (),
154- /* IsUnavailableInEmbedded*/ false , deprecated};
157+ /* IsUnavailableInEmbedded*/ false , deprecated,
158+ /* AllowsUnsafe*/ false };
155159 return AvailabilityContext (Storage::get (platformInfo, ctx));
156160}
157161
@@ -170,6 +174,10 @@ bool AvailabilityContext::isUnavailableInEmbedded() const {
170174 return Info->Platform .IsUnavailableInEmbedded ;
171175}
172176
177+ bool AvailabilityContext::allowsUnsafe () const {
178+ return Info->Platform .AllowsUnsafe ;
179+ }
180+
173181bool AvailabilityContext::isDeprecated () const {
174182 return Info->Platform .IsDeprecated ;
175183}
@@ -233,6 +241,9 @@ void AvailabilityContext::print(llvm::raw_ostream &os) const {
233241
234242 if (isDeprecated ())
235243 os << " deprecated" ;
244+
245+ if (allowsUnsafe ())
246+ os << " allows_unsafe" ;
236247}
237248
238249void AvailabilityContext::dump () const { print (llvm::errs ()); }
0 commit comments