@@ -177,6 +177,25 @@ class PrintMetadataSource
177
177
}
178
178
};
179
179
180
+ // / Determine whether the given generic nominal that involves inverse
181
+ // / requirements (e.g., Optional, Span) is always available for demangling
182
+ // / purposes.
183
+ static bool nominalIsAlwaysAvailableForDemangling (const NominalTypeDecl *nom) {
184
+ // Only consider standard library types for this.
185
+ if (!nom->getModuleContext ()->isStdlibModule ())
186
+ return false ;
187
+
188
+ // If there's an @_originallyDefined(in:) attribute, then the nominal is
189
+ // not always available for demangling.
190
+ for (auto attr: nom->getAttrs ().getAttributes <OriginallyDefinedInAttr>()) {
191
+ if (!attr->isInvalid () && attr->isActivePlatform (nom->getASTContext ()))
192
+ return false ;
193
+ }
194
+
195
+ // Everything else is available.
196
+ return true ;
197
+ }
198
+
180
199
std::optional<llvm::VersionTuple>
181
200
getRuntimeVersionThatSupportsDemanglingType (CanType type) {
182
201
enum VersionRequirement {
@@ -185,9 +204,10 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
185
204
Swift_5_5,
186
205
Swift_6_0,
187
206
Swift_6_1,
207
+ Swift_6_2,
188
208
189
209
// Short-circuit if we find this requirement.
190
- Latest = Swift_6_1
210
+ Latest = Swift_6_2
191
211
};
192
212
193
213
VersionRequirement latestRequirement = None;
@@ -204,6 +224,11 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
204
224
auto isolation = fn->getIsolation ();
205
225
auto sendingResult = fn->hasSendingResult ();
206
226
227
+ // The mangling for nonisolated(nonsending) function types was introduced
228
+ // in Swift 6.2.
229
+ if (isolation.isNonIsolatedCaller ())
230
+ return addRequirement (Swift_6_2);
231
+
207
232
// The Swift 6.1 runtime fixes a bug preventing successful demangling
208
233
// when @isolated(any) or global actor isolation is combined with a
209
234
// sending result.
@@ -246,16 +271,16 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
246
271
// / signature uses NoncopyableGenerics. Since inverses are mangled into
247
272
// / symbols, a Swift 6.0+ runtime is generally needed to demangle them.
248
273
// /
249
- // / We make an exception for types in the stdlib, like Optional, since the
250
- // / runtime should still be able to demangle them, based on the availability
251
- // / of the type.
274
+ // / We make an exception for some types in the stdlib, like Optional, since
275
+ // / the runtime should still be able to demangle them, based on the
276
+ // / availability of the type.
252
277
if (auto nominalTy = dyn_cast<NominalOrBoundGenericNominalType>(t)) {
253
278
auto *nom = nominalTy->getDecl ();
254
279
if (auto sig = nom->getGenericSignature ()) {
255
280
SmallVector<InverseRequirement, 2 > inverses;
256
281
SmallVector<Requirement, 2 > reqs;
257
282
sig->getRequirementsWithInverses (reqs, inverses);
258
- if (!inverses.empty () && !nom-> getModuleContext ()-> isStdlibModule ( )) {
283
+ if (!inverses.empty () && !nominalIsAlwaysAvailableForDemangling (nom )) {
259
284
return addRequirement (Swift_6_0);
260
285
}
261
286
}
@@ -271,6 +296,7 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
271
296
});
272
297
273
298
switch (latestRequirement) {
299
+ case Swift_6_2: return llvm::VersionTuple (6 , 2 );
274
300
case Swift_6_1: return llvm::VersionTuple (6 , 1 );
275
301
case Swift_6_0: return llvm::VersionTuple (6 , 0 );
276
302
case Swift_5_5: return llvm::VersionTuple (5 , 5 );
0 commit comments