File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1597,6 +1597,9 @@ class LinkEntity {
1597
1597
getKind () == Kind::DispatchThunkAllocator ||
1598
1598
getKind () == Kind::DispatchThunkDerivative;
1599
1599
}
1600
+ bool isNominalTypeDescriptor () const {
1601
+ return getKind () == Kind::NominalTypeDescriptor;
1602
+ }
1600
1603
1601
1604
// / Determine whether this entity will be weak-imported.
1602
1605
bool isWeakImported (ModuleDecl *module ) const ;
Original file line number Diff line number Diff line change @@ -2412,6 +2412,22 @@ LinkInfo LinkInfo::get(const UniversalLinkageInfo &linkInfo,
2412
2412
isKnownLocal = MD == swiftModule || MD->isStaticLibrary ();
2413
2413
}
2414
2414
2415
+ if (!isKnownLocal && !isDefinition) {
2416
+ if (auto *entityDC = entity.getDeclContextForEmission ()) {
2417
+ auto *entitySF = entityDC->getModuleScopeContext ();
2418
+ bool clangImportedEntity = isa<ClangModuleUnit>(entitySF);
2419
+ // Nominal type descriptor for a type imported from a Clang module
2420
+ // is always a local declaration as it's generated on demand. When WMO is off, it's emitted into
2421
+ // the current file's object file. When WMO is on, it's emitted into
2422
+ // one of the object files in the current module, and thus it's never
2423
+ // imported from outside of the module.
2424
+ if (clangImportedEntity &&
2425
+ entity.isNominalTypeDescriptor ()) {
2426
+ isKnownLocal = true ;
2427
+ }
2428
+ }
2429
+ }
2430
+
2415
2431
bool weakImported = entity.isWeakImported (swiftModule);
2416
2432
result.IRL = getIRLinkage (result.Name , linkInfo,
2417
2433
entity.getLinkage (isDefinition), isDefinition,
You can’t perform that action at this time.
0 commit comments