Skip to content

Commit a8fec6f

Browse files
committed
[Swiftify] Always skip safe wrappers when building the stdlib
_SwiftifyImport assumes types like Swift.Int, Swift.UnsafePointer<T> and Swift.Span<T> are available. This is not the case when building the stdlib itself. Disable safe interop in the stdlib to prevent errors. This currently has no effect, but will when this feature is enabled by default, which I have manually tested.
1 parent d653b0c commit a8fec6f

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,10 @@ namespace swift {
11481148
/// ones to apply.
11491149
bool LoadVersionIndependentAPINotes = false;
11501150

1151+
/// Whether the importer should skip SafeInteropWrappers, even though the
1152+
/// feature is enabled.
1153+
bool DisableSafeInteropWrappers = false;
1154+
11511155
/// Return a hash code of any components from these options that should
11521156
/// contribute to a Swift Bridging PCH hash.
11531157
llvm::hash_code getPCHHashComponents() const {

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9484,7 +9484,8 @@ static StringRef getAttributeName(const clang::CountAttributedType *CAT) {
94849484
}
94859485

94869486
void ClangImporter::Implementation::swiftify(AbstractFunctionDecl *MappedDecl) {
9487-
if (!SwiftContext.LangOpts.hasFeature(Feature::SafeInteropWrappers))
9487+
if (!SwiftContext.LangOpts.hasFeature(Feature::SafeInteropWrappers) ||
9488+
SwiftContext.ClangImporterOpts.DisableSafeInteropWrappers)
94889489
return;
94899490
auto ClangDecl =
94909491
dyn_cast_or_null<clang::FunctionDecl>(MappedDecl->getClangDecl());

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
21752175

21762176
Opts.LoadVersionIndependentAPINotes |= Args.hasArg(OPT_version_independent_apinotes);
21772177

2178+
Opts.DisableSafeInteropWrappers |= FrontendOpts.ParseStdlib;
2179+
21782180
if (FrontendOpts.DisableImplicitModules)
21792181
Opts.DisableImplicitClangModules = true;
21802182

0 commit comments

Comments
 (0)