Skip to content
Draft
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
11 changes: 0 additions & 11 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ namespace swift {
/// disabled because it is not complete.
bool EnableCXXInterop = false;

/// The C++ interoperability source compatibility version. Defaults
/// to the Swift language version.
version::Version cxxInteropCompatVersion;

/// What version of C++ interoperability a textual interface was originally
/// generated with (if at all).
std::optional<version::Version> FormalCxxInteropMode;
Expand Down Expand Up @@ -753,13 +749,6 @@ namespace swift {
return EffectiveLanguageVersion.isVersionAtLeast(major, minor);
}

/// Whether the C++ interoperability compatibility version is at least
/// 'major'.
bool isCxxInteropCompatVersionAtLeast(unsigned major,
unsigned minor = 0) const {
return cxxInteropCompatVersion.isVersionAtLeast(major, minor);
}

/// Sets the "_hasAtomicBitWidth" conditional.
void setHasAtomicBitWidth(llvm::Triple triple);

Expand Down
5 changes: 0 additions & 5 deletions include/swift/Basic/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ StringRef getCurrentCompilerSerializationTag();
/// same serialization tag.
StringRef getCurrentCompilerChannel();

/// Retrieves the value of the upcoming C++ interoperability compatibility
/// version that's going to be presented as some new concrete version to the
/// users.
unsigned getUpcomingCxxInteropCompatVersion();

/// Retrieves the version of the running compiler. It could be a tag or
/// a "development" version that only has major/minor.
std::string getCompilerVersion();
Expand Down
4 changes: 0 additions & 4 deletions lib/Basic/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,6 @@ StringRef getCurrentCompilerChannel() {
return StringRef();
}

unsigned getUpcomingCxxInteropCompatVersion() {
return SWIFT_VERSION_MAJOR + 1;
}

std::string getCompilerVersion() {
std::string buf;
llvm::raw_string_ostream OS(buf);
Expand Down
11 changes: 0 additions & 11 deletions lib/ClangImporter/ImporterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,17 +624,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
void getMangledName(clang::MangleContext *mangler,
const clang::NamedDecl *clangDecl, raw_ostream &os);

/// Whether the C++ interoperability compatibility version is at least
/// 'major'.
///
/// Use the
/// `isCxxInteropCompatVersionAtLeast(version::getUpcomingCxxInteropCompatVersion())`
/// check when making a source breaking C++ interop change.
bool isCxxInteropCompatVersionAtLeast(unsigned major,
unsigned minor = 0) const {
return SwiftContext.LangOpts.isCxxInteropCompatVersionAtLeast(major, minor);
}

private:
/// The Importer may be configured to load modules of a different OS Version
/// than the underlying Swift compilation. This is the `TargetOptions`
Expand Down
24 changes: 2 additions & 22 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,17 +667,9 @@ static std::pair<CxxCompatMode, version::Version>
validateCxxInteropCompatibilityMode(StringRef mode) {
if (mode == "off")
return {CxxCompatMode::off, {}};
if (mode == "default")
if (mode == "default" || mode == "upcoming-swift" || mode == "swift-6" ||
mode == "swift-5.9")
return {CxxCompatMode::enabled, {}};
if (mode == "upcoming-swift")
return {CxxCompatMode::enabled,
version::Version({version::getUpcomingCxxInteropCompatVersion()})};
if (mode == "swift-6")
return {CxxCompatMode::enabled, version::Version({6})};
// Swift-5.9 corresponds to the Swift 5 language mode when
// Swift 5 is the default language version.
if (mode == "swift-5.9")
return {CxxCompatMode::enabled, version::Version({5})};
// Note: If this is updated, corresponding code in
// InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl needs
// to be updated also.
Expand Down Expand Up @@ -709,13 +701,6 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args,
auto interopCompatMode = validateCxxInteropCompatibilityMode(A->getValue());
EnableCXXInterop |=
(interopCompatMode.first == CxxCompatMode::enabled);
if (EnableCXXInterop) {
cxxInteropCompatVersion = interopCompatMode.second;
// The default is tied to the current language version.
if (cxxInteropCompatVersion.empty())
cxxInteropCompatVersion =
EffectiveLanguageVersion.asMajorVersion();
}

if (interopCompatMode.first == CxxCompatMode::invalid)
diagnoseCxxInteropCompatMode(A, Args, Diags);
Expand All @@ -725,11 +710,6 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args,
Diags.diagnose(SourceLoc(), diag::enable_interop_flag_deprecated);
Diags.diagnose(SourceLoc(), diag::swift_will_maintain_compat);
EnableCXXInterop |= true;
// Using the deprecated option only forces the 'swift-5.9' compat
// mode.
if (cxxInteropCompatVersion.empty())
cxxInteropCompatVersion =
validateCxxInteropCompatibilityMode("swift-5.9").second;
}

if (Arg *A = Args.getLastArg(options::OPT_formal_cxx_interoperability_mode)) {
Expand Down
18 changes: 1 addition & 17 deletions lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,23 +2026,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
if (langOpts.EnableCXXInterop) {
// Modelled after a reverse of validateCxxInteropCompatibilityMode
genericSubInvocation.getLangOptions().EnableCXXInterop = true;
genericSubInvocation.getLangOptions().cxxInteropCompatVersion =
langOpts.cxxInteropCompatVersion;
std::string compatVersion;
if (langOpts.cxxInteropCompatVersion.empty())
compatVersion = "default";
else if (langOpts.cxxInteropCompatVersion[0] == 5)
compatVersion = "swift-5.9";
else if (langOpts.cxxInteropCompatVersion[0] == 6)
compatVersion = "swift-6";
else if (langOpts.cxxInteropCompatVersion[0] ==
version::getUpcomingCxxInteropCompatVersion())
compatVersion = "upcoming-swift";
else // TODO: This may need to be updated once more versions are added
compatVersion = "default";

GenericArgs.push_back(
ArgSaver.save("-cxx-interoperability-mode=" + compatVersion));
GenericArgs.push_back(ArgSaver.save("-cxx-interoperability-mode=default"));

if (!langOpts.isUsingPlatformDefaultCXXStdlib() &&
langOpts.CXXStdlib == CXXStdlibKind::Libcxx) {
Expand Down
16 changes: 1 addition & 15 deletions tools/swift-ide-test/swift-ide-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4626,23 +4626,9 @@ int main(int argc, char *argv[]) {
InitInvok.getLangOptions().EnableObjCInterop =
llvm::Triple(options::Triple).isOSDarwin();
}
if (options::EnableCxxInterop) {
if (options::EnableCxxInterop || !options::CxxInteropVersion.empty()) {
InitInvok.getLangOptions().EnableCXXInterop = true;
}
if (!options::CxxInteropVersion.empty()) {
InitInvok.getLangOptions().EnableCXXInterop = true;
if (options::CxxInteropVersion == "upcoming-swift")
InitInvok.getLangOptions().cxxInteropCompatVersion =
version::Version({version::getUpcomingCxxInteropCompatVersion()});
else if (options::CxxInteropVersion == "swift-6")
InitInvok.getLangOptions().cxxInteropCompatVersion =
version::Version({6});
else if (options::CxxInteropVersion == "swift-5.9")
InitInvok.getLangOptions().cxxInteropCompatVersion =
version::Version({5, 9});
else
llvm::errs() << "invalid CxxInteropVersion\n";
}
if (options::CxxInteropGettersSettersAsProperties) {
InitInvok.getLangOptions().CxxInteropGettersSettersAsProperties = true;
}
Expand Down