Skip to content

Commit a6b30c4

Browse files
authored
Merge pull request #85869 from egorzhdan/egorzhdan/remove-interop-compat-version
[cxx-interop] Remove compatibility versions
2 parents f25b4b4 + 69be33d commit a6b30c4

File tree

7 files changed

+4
-85
lines changed

7 files changed

+4
-85
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,6 @@ namespace swift {
333333
/// disabled because it is not complete.
334334
bool EnableCXXInterop = false;
335335

336-
/// The C++ interoperability source compatibility version. Defaults
337-
/// to the Swift language version.
338-
version::Version cxxInteropCompatVersion;
339-
340336
/// What version of C++ interoperability a textual interface was originally
341337
/// generated with (if at all).
342338
std::optional<version::Version> FormalCxxInteropMode;
@@ -753,13 +749,6 @@ namespace swift {
753749
return EffectiveLanguageVersion.isVersionAtLeast(major, minor);
754750
}
755751

756-
/// Whether the C++ interoperability compatibility version is at least
757-
/// 'major'.
758-
bool isCxxInteropCompatVersionAtLeast(unsigned major,
759-
unsigned minor = 0) const {
760-
return cxxInteropCompatVersion.isVersionAtLeast(major, minor);
761-
}
762-
763752
/// Sets the "_hasAtomicBitWidth" conditional.
764753
void setHasAtomicBitWidth(llvm::Triple triple);
765754

include/swift/Basic/Version.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ StringRef getCurrentCompilerSerializationTag();
184184
/// same serialization tag.
185185
StringRef getCurrentCompilerChannel();
186186

187-
/// Retrieves the value of the upcoming C++ interoperability compatibility
188-
/// version that's going to be presented as some new concrete version to the
189-
/// users.
190-
unsigned getUpcomingCxxInteropCompatVersion();
191-
192187
/// Retrieves the version of the running compiler. It could be a tag or
193188
/// a "development" version that only has major/minor.
194189
std::string getCompilerVersion();

lib/Basic/Version.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,6 @@ StringRef getCurrentCompilerChannel() {
330330
return StringRef();
331331
}
332332

333-
unsigned getUpcomingCxxInteropCompatVersion() {
334-
return SWIFT_VERSION_MAJOR + 1;
335-
}
336-
337333
std::string getCompilerVersion() {
338334
std::string buf;
339335
llvm::raw_string_ostream OS(buf);

lib/ClangImporter/ImporterImpl.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -624,17 +624,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
624624
void getMangledName(clang::MangleContext *mangler,
625625
const clang::NamedDecl *clangDecl, raw_ostream &os);
626626

627-
/// Whether the C++ interoperability compatibility version is at least
628-
/// 'major'.
629-
///
630-
/// Use the
631-
/// `isCxxInteropCompatVersionAtLeast(version::getUpcomingCxxInteropCompatVersion())`
632-
/// check when making a source breaking C++ interop change.
633-
bool isCxxInteropCompatVersionAtLeast(unsigned major,
634-
unsigned minor = 0) const {
635-
return SwiftContext.LangOpts.isCxxInteropCompatVersionAtLeast(major, minor);
636-
}
637-
638627
private:
639628
/// The Importer may be configured to load modules of a different OS Version
640629
/// than the underlying Swift compilation. This is the `TargetOptions`

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -668,17 +668,9 @@ static std::pair<CxxCompatMode, version::Version>
668668
validateCxxInteropCompatibilityMode(StringRef mode) {
669669
if (mode == "off")
670670
return {CxxCompatMode::off, {}};
671-
if (mode == "default")
671+
if (mode == "default" || mode == "upcoming-swift" || mode == "swift-6" ||
672+
mode == "swift-5.9")
672673
return {CxxCompatMode::enabled, {}};
673-
if (mode == "upcoming-swift")
674-
return {CxxCompatMode::enabled,
675-
version::Version({version::getUpcomingCxxInteropCompatVersion()})};
676-
if (mode == "swift-6")
677-
return {CxxCompatMode::enabled, version::Version({6})};
678-
// Swift-5.9 corresponds to the Swift 5 language mode when
679-
// Swift 5 is the default language version.
680-
if (mode == "swift-5.9")
681-
return {CxxCompatMode::enabled, version::Version({5})};
682674
// Note: If this is updated, corresponding code in
683675
// InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl needs
684676
// to be updated also.
@@ -710,13 +702,6 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args,
710702
auto interopCompatMode = validateCxxInteropCompatibilityMode(A->getValue());
711703
EnableCXXInterop |=
712704
(interopCompatMode.first == CxxCompatMode::enabled);
713-
if (EnableCXXInterop) {
714-
cxxInteropCompatVersion = interopCompatMode.second;
715-
// The default is tied to the current language version.
716-
if (cxxInteropCompatVersion.empty())
717-
cxxInteropCompatVersion =
718-
EffectiveLanguageVersion.asMajorVersion();
719-
}
720705

721706
if (interopCompatMode.first == CxxCompatMode::invalid)
722707
diagnoseCxxInteropCompatMode(A, Args, Diags);
@@ -726,11 +711,6 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args,
726711
Diags.diagnose(SourceLoc(), diag::enable_interop_flag_deprecated);
727712
Diags.diagnose(SourceLoc(), diag::swift_will_maintain_compat);
728713
EnableCXXInterop |= true;
729-
// Using the deprecated option only forces the 'swift-5.9' compat
730-
// mode.
731-
if (cxxInteropCompatVersion.empty())
732-
cxxInteropCompatVersion =
733-
validateCxxInteropCompatibilityMode("swift-5.9").second;
734714
}
735715

736716
if (Arg *A = Args.getLastArg(options::OPT_formal_cxx_interoperability_mode)) {

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,23 +2026,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
20262026
if (langOpts.EnableCXXInterop) {
20272027
// Modelled after a reverse of validateCxxInteropCompatibilityMode
20282028
genericSubInvocation.getLangOptions().EnableCXXInterop = true;
2029-
genericSubInvocation.getLangOptions().cxxInteropCompatVersion =
2030-
langOpts.cxxInteropCompatVersion;
2031-
std::string compatVersion;
2032-
if (langOpts.cxxInteropCompatVersion.empty())
2033-
compatVersion = "default";
2034-
else if (langOpts.cxxInteropCompatVersion[0] == 5)
2035-
compatVersion = "swift-5.9";
2036-
else if (langOpts.cxxInteropCompatVersion[0] == 6)
2037-
compatVersion = "swift-6";
2038-
else if (langOpts.cxxInteropCompatVersion[0] ==
2039-
version::getUpcomingCxxInteropCompatVersion())
2040-
compatVersion = "upcoming-swift";
2041-
else // TODO: This may need to be updated once more versions are added
2042-
compatVersion = "default";
2043-
2044-
GenericArgs.push_back(
2045-
ArgSaver.save("-cxx-interoperability-mode=" + compatVersion));
2029+
GenericArgs.push_back(ArgSaver.save("-cxx-interoperability-mode=default"));
20462030

20472031
if (!langOpts.isUsingPlatformDefaultCXXStdlib() &&
20482032
langOpts.CXXStdlib == CXXStdlibKind::Libcxx) {

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,23 +4626,9 @@ int main(int argc, char *argv[]) {
46264626
InitInvok.getLangOptions().EnableObjCInterop =
46274627
llvm::Triple(options::Triple).isOSDarwin();
46284628
}
4629-
if (options::EnableCxxInterop) {
4629+
if (options::EnableCxxInterop || !options::CxxInteropVersion.empty()) {
46304630
InitInvok.getLangOptions().EnableCXXInterop = true;
46314631
}
4632-
if (!options::CxxInteropVersion.empty()) {
4633-
InitInvok.getLangOptions().EnableCXXInterop = true;
4634-
if (options::CxxInteropVersion == "upcoming-swift")
4635-
InitInvok.getLangOptions().cxxInteropCompatVersion =
4636-
version::Version({version::getUpcomingCxxInteropCompatVersion()});
4637-
else if (options::CxxInteropVersion == "swift-6")
4638-
InitInvok.getLangOptions().cxxInteropCompatVersion =
4639-
version::Version({6});
4640-
else if (options::CxxInteropVersion == "swift-5.9")
4641-
InitInvok.getLangOptions().cxxInteropCompatVersion =
4642-
version::Version({5, 9});
4643-
else
4644-
llvm::errs() << "invalid CxxInteropVersion\n";
4645-
}
46464632
if (options::CxxInteropGettersSettersAsProperties) {
46474633
InitInvok.getLangOptions().CxxInteropGettersSettersAsProperties = true;
46484634
}

0 commit comments

Comments
 (0)