Skip to content

Commit d72006e

Browse files
committed
[cxx-interop] Workaround compiler error when importing CoreGraphics with C++ interop
The CoreGraphics overlay refers to symbols declared via `CF_OPTIONS` macro, which is causing issues in C++ language mode due to the macro definition being different. This teaches the module interface loader to drop the C++ interop flag when rebuilding the CoreGraphics overlay from its interface. rdar://142762174
1 parent 5f79319 commit d72006e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,9 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
22022202

22032203
// FIXME: Hack for Darwin.swiftmodule, which cannot be rebuilt with C++
22042204
// interop enabled by the Swift CI because it uses an old host SDK.
2205-
if (moduleName == "Darwin") {
2205+
// FIXME: Hack for CoreGraphics.swiftmodule, which cannot be rebuilt because
2206+
// of a CF_OPTIONS bug (rdar://142762174).
2207+
if (moduleName == "Darwin" || moduleName == "CoreGraphics") {
22062208
subInvocation.getLangOptions().EnableCXXInterop = false;
22072209
subInvocation.getLangOptions().cxxInteropCompatVersion = {};
22082210
BuildArgs.erase(llvm::remove_if(BuildArgs,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 CoreGraphics
7+
8+
var _: CGBitmapInfo! = nil
9+

0 commit comments

Comments
 (0)