Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we anticipate other cases where we want to disable the wrappers? I wonder if we should always check directly for whether we are building the stdlib instead of having a new flag. I have no strong feelings here though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of any other cases, but ClangImporter doesn't seem to have access to swift::FrontendOptions from what I could tell.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. We have -disable-experimental-feature, although I'm not sure if we model having an on-by-default feature that is then disabled.


/// Return a hash code of any components from these options that should
/// contribute to a Swift Bridging PCH hash.
llvm::hash_code getPCHHashComponents() const {
Expand Down
3 changes: 2 additions & 1 deletion lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<clang::FunctionDecl>(MappedDecl->getClangDecl());
Expand Down
2 changes: 2 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down