Skip to content

Commit c7021ae

Browse files
committed
[cxx-interop] Workaround name lookup issues with namespace simd
On Apple platforms, a system module `simd` declares a `namespace simd` under `#if defined(__cplusplus)`. This namespace defines C++ overlays of the simd types, but these types are already refined for Swift separately, so it's not necessary to import this namespace. This is the same issue previously encountered for the `os` module, work around it in the same way. rdar://143007477
1 parent ccdce9f commit c7021ae

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,14 @@ namespace {
11661166
decl->getOwningModule() &&
11671167
decl->getOwningModule()->getTopLevelModuleName() == "os")
11681168
return nullptr;
1169+
// Workaround for simd module declaring `namespace simd` on Darwin,
1170+
// causing name lookup issues. That namespace declares C++ overlays of
1171+
// types that are already refined for Swift, so let's not import the
1172+
// namespace (rdar://143007477).
1173+
if (decl->getIdentifier() && decl->getName() == "simd" &&
1174+
decl->getOwningModule() &&
1175+
decl->getOwningModule()->getTopLevelModuleName() == "simd")
1176+
return nullptr;
11691177
// If this is a top-level namespace, don't put it in the module we're
11701178
// importing, put it in the "__ObjC" module that is implicitly imported.
11711179
if (!decl->getParent()->isNamespace())
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs -cxx-interoperability-mode=default %s
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: VENDOR=apple
5+
6+
import simd
7+
8+
var _: simd.simd_quatf! = nil

0 commit comments

Comments
 (0)