diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index 4687beea7d70d..3e89fc1062711 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -1148,6 +1148,10 @@ namespace swift { /// ones to apply. bool LoadVersionIndependentAPINotes = false; + /// Whether the importer should skip SafeInteropWrappers, even though the + /// feature is enabled. + bool DisableSafeInteropWrappers = false; + /// Return a hash code of any components from these options that should /// contribute to a Swift Bridging PCH hash. llvm::hash_code getPCHHashComponents() const { diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index f2db92c2f1100..a0bf7db57b502 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -9484,7 +9484,8 @@ static StringRef getAttributeName(const clang::CountAttributedType *CAT) { } void ClangImporter::Implementation::swiftify(AbstractFunctionDecl *MappedDecl) { - if (!SwiftContext.LangOpts.hasFeature(Feature::SafeInteropWrappers)) + if (!SwiftContext.LangOpts.hasFeature(Feature::SafeInteropWrappers) || + SwiftContext.ClangImporterOpts.DisableSafeInteropWrappers) return; auto ClangDecl = dyn_cast_or_null(MappedDecl->getClangDecl()); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 773c30ffd3f84..6672844e2f809 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -2175,6 +2175,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args, Opts.LoadVersionIndependentAPINotes |= Args.hasArg(OPT_version_independent_apinotes); + Opts.DisableSafeInteropWrappers |= FrontendOpts.ParseStdlib; + if (FrontendOpts.DisableImplicitModules) Opts.DisableImplicitClangModules = true;