@@ -351,8 +351,14 @@ void ClangImporter::Implementation::forEachDistinctName(
351
351
llvm::function_ref<bool (ImportedName, ImportNameVersion)> action) {
352
352
using ImportNameKey = std::pair<DeclName, EffectiveClangContext>;
353
353
SmallVector<ImportNameKey, 8 > seenNames;
354
- forEachImportNameVersionFromCurrent (CurrentVersion,
355
- [&](ImportNameVersion nameVersion) {
354
+
355
+ ImportedName newName = importFullName (decl, CurrentVersion);
356
+ ImportNameKey key (newName, newName.getEffectiveContext ());
357
+ if (action (newName, CurrentVersion))
358
+ seenNames.push_back (key);
359
+
360
+ CurrentVersion.forEachOtherImportNameVersion (
361
+ [&](ImportNameVersion nameVersion) {
356
362
// Check to see if the name is different.
357
363
ImportedName newName = importFullName (decl, nameVersion);
358
364
ImportNameKey key (newName, newName.getEffectiveContext ());
@@ -1947,7 +1953,7 @@ namespace {
1947
1953
Optional<ImportedName> &correctSwiftName) {
1948
1954
ImportNameVersion canonicalVersion = getActiveSwiftVersion ();
1949
1955
if (isa<clang::TypeDecl>(D) || isa<clang::ObjCContainerDecl>(D)) {
1950
- canonicalVersion = ImportNameVersion::ForTypes ;
1956
+ canonicalVersion = ImportNameVersion::forTypes () ;
1951
1957
}
1952
1958
correctSwiftName = None;
1953
1959
@@ -2133,36 +2139,38 @@ namespace {
2133
2139
// If we're importing a global as a member, we need to provide the
2134
2140
// effective context.
2135
2141
Impl.printSwiftName (
2136
- correctSwiftName,
2142
+ correctSwiftName, getActiveSwiftVersion (),
2137
2143
/* fullyQualified=*/ correctSwiftName.importAsMember (), os);
2138
2144
}
2139
2145
2140
- unsigned majorVersion = majorVersionNumberForNameVersion (getVersion ());
2141
2146
DeclAttribute *attr;
2142
- if (isActiveSwiftVersion () || getVersion () == ImportNameVersion::Raw ) {
2147
+ if (isActiveSwiftVersion () || getVersion () == ImportNameVersion::raw () ) {
2143
2148
// "Raw" is the Objective-C name, which was never available in Swift.
2144
2149
// Variants within the active version are usually declarations that
2145
2150
// have been superseded, like the accessors of a property.
2146
2151
attr = AvailableAttr::createPlatformAgnostic (
2147
2152
ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
2148
2153
PlatformAgnosticAvailabilityKind::UnavailableInSwift);
2149
- } else if (getVersion () < getActiveSwiftVersion ()) {
2150
- // A Swift 2 name, for example, was obsoleted in Swift 3.
2151
- attr = AvailableAttr::createPlatformAgnostic (
2152
- ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
2153
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
2154
- clang::VersionTuple (majorVersion + 1 ));
2155
2154
} else {
2156
- // Future names are introduced in their future version.
2157
- assert (getVersion () > getActiveSwiftVersion ());
2158
- attr = new (ctx) AvailableAttr (
2159
- SourceLoc (), SourceRange (), PlatformKind::none,
2160
- /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
2161
- /* Introduced*/ clang::VersionTuple (majorVersion), SourceRange (),
2162
- /* Deprecated*/ clang::VersionTuple (), SourceRange (),
2163
- /* Obsoleted*/ clang::VersionTuple (), SourceRange (),
2164
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
2165
- /* Implicit*/ false );
2155
+ unsigned majorVersion = getVersion ().majorVersionNumber ();
2156
+ if (getVersion () < getActiveSwiftVersion ()) {
2157
+ // A Swift 2 name, for example, was obsoleted in Swift 3.
2158
+ attr = AvailableAttr::createPlatformAgnostic (
2159
+ ctx, /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
2160
+ PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
2161
+ clang::VersionTuple (majorVersion + 1 ));
2162
+ } else {
2163
+ // Future names are introduced in their future version.
2164
+ assert (getVersion () > getActiveSwiftVersion ());
2165
+ attr = new (ctx) AvailableAttr (
2166
+ SourceLoc (), SourceRange (), PlatformKind::none,
2167
+ /* Message*/ StringRef (), ctx.AllocateCopy (renamed.str ()),
2168
+ /* Introduced*/ clang::VersionTuple (majorVersion), SourceRange (),
2169
+ /* Deprecated*/ clang::VersionTuple (), SourceRange (),
2170
+ /* Obsoleted*/ clang::VersionTuple (), SourceRange (),
2171
+ PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
2172
+ /* Implicit*/ false );
2173
+ }
2166
2174
}
2167
2175
2168
2176
decl->getAttrs ().add (attr);
@@ -4854,7 +4862,7 @@ Decl *SwiftDeclConverter::importCompatibilityTypeAlias(
4854
4862
// we don't care.
4855
4863
Decl *importedDecl = nullptr ;
4856
4864
if (getVersion () >= getActiveSwiftVersion ())
4857
- importedDecl = Impl.importDecl (decl, ImportNameVersion::ForTypes );
4865
+ importedDecl = Impl.importDecl (decl, ImportNameVersion::forTypes () );
4858
4866
if (!importedDecl && getVersion () != getActiveSwiftVersion ())
4859
4867
importedDecl = Impl.importDecl (decl, getActiveSwiftVersion ());
4860
4868
auto typeDecl = dyn_cast_or_null<TypeDecl>(importedDecl);
0 commit comments