Skip to content

Commit 4b43e8c

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-rebranch
2 parents 380670f + fc9840f commit 4b43e8c

File tree

9 files changed

+60
-6
lines changed

9 files changed

+60
-6
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3924,9 +3924,44 @@ namespace {
39243924
}
39253925

39263926
Decl *VisitUsingShadowDecl(const clang::UsingShadowDecl *decl) {
3927-
// Using shadow declarations are not imported; rather, name lookup just
3928-
// looks through them.
3929-
return nullptr;
3927+
// Only import types for now.
3928+
if (!isa<clang::TypeDecl>(decl->getUnderlyingDecl()))
3929+
return nullptr;
3930+
3931+
Optional<ImportedName> correctSwiftName;
3932+
auto importedName = importFullName(decl, correctSwiftName);
3933+
auto Name = importedName.getDeclName().getBaseIdentifier();
3934+
if (Name.empty())
3935+
return nullptr;
3936+
3937+
// If we've been asked to produce a compatibility stub, handle it via a
3938+
// typealias.
3939+
if (correctSwiftName)
3940+
return importCompatibilityTypeAlias(decl, importedName,
3941+
*correctSwiftName);
3942+
3943+
auto DC =
3944+
Impl.importDeclContextOf(decl, importedName.getEffectiveContext());
3945+
if (!DC)
3946+
return nullptr;
3947+
3948+
Decl *SwiftDecl = Impl.importDecl(decl->getUnderlyingDecl(), getActiveSwiftVersion());
3949+
const TypeDecl *SwiftTypeDecl = dyn_cast<TypeDecl>(SwiftDecl);
3950+
3951+
if (!SwiftTypeDecl)
3952+
return nullptr;
3953+
3954+
auto Loc = Impl.importSourceLoc(decl->getLocation());
3955+
auto Result = Impl.createDeclWithClangNode<TypeAliasDecl>(
3956+
decl,
3957+
AccessLevel::Public,
3958+
Impl.importSourceLoc(decl->getBeginLoc()),
3959+
SourceLoc(), Name,
3960+
Loc,
3961+
/*genericparams*/nullptr, DC);
3962+
Result->setUnderlyingType(SwiftTypeDecl->getDeclaredInterfaceType());
3963+
3964+
return Result;
39303965
}
39313966

39323967
/// Add an @objc(name) attribute with the given, optional name expressed as

test/ClangImporter/Inputs/custom-modules/cxx_interop.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Ensure c++ features are used.
44
namespace ns {
55
class T {};
6+
class NamespacedType {};
67

78
T *doMakeT();
89
} // namespace ns
@@ -16,7 +17,9 @@ Basic makeA();
1617

1718
ns::T* makeT();
1819
void useT(ns::T* v);
20+
1921
using namespacedT = ns::T;
22+
using ns::NamespacedType;
2023

2124
class Methods {
2225
public:

test/ClangImporter/cxx_interop_ir.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ func reflectionInfo(arg: namespacedT) -> Any.Type {
1919
func namespaceManglesIntoName(arg: namespacedT) {
2020
}
2121

22+
// CHECK: define hidden swiftcc void @"$s6cxx_ir42namespaceManglesIntoNameForUsingShadowDecl3argySo2nsV14NamespacedTypeV_tF"
23+
func namespaceManglesIntoNameForUsingShadowDecl(arg: NamespacedType) {
24+
}
25+
2226
// CHECK-LABEL: define hidden swiftcc void @"$s6cxx_ir14accessNSMemberyyF"()
2327
// CHECK: %0 = call %"class.ns::T"* @{{_ZN2ns7doMakeTEv|"\?doMakeT@ns@@YAPEAVT@1@XZ"}}()
2428
// CHECK: call void @{{_Z4useTPN2ns1TE|"\?useT@@YAXPE?AVT@ns@@@Z"}}(%"class.ns::T"* %2)

test/api-digester/Inputs/cake_baseline/cake.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,5 @@ public class Zoo {
193193
return Cat()
194194
}
195195
}
196+
197+
public func returnFunctionTypeOwnershipChange() -> (C1) -> () { return { _ in } }

test/api-digester/Inputs/cake_current/cake.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,5 @@ public class Zoo {
200200
return Dog()
201201
}
202202
}
203+
204+
public func returnFunctionTypeOwnershipChange() -> (__owned C1) -> () { return { _ in } }

test/api-digester/Outputs/Cake-abi.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ cake: Func Somestruct2.foo1(_:) has parameter 0 type change from C3 to C1
4444
cake: Func Zoo.getCurrentAnimalInlinable() has return type change from Cat to Dog
4545
cake: Func ownershipChange(_:_:) has parameter 0 changing from InOut to Default
4646
cake: Func ownershipChange(_:_:) has parameter 1 changing from Shared to Owned
47+
cake: Func returnFunctionTypeOwnershipChange() has return type change from (C1) -> () to (__owned C1) -> ()
4748
cake: Var Zoo.current has declared type change from Cat to Dog
4849

4950
/* Decl Attribute changes */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Func BidirectionalCollection.difference(from:by:) has parameter 1 type change from (τ_0_0.Element, τ_1_0.Element) -> Bool to (τ_1_0.Element, τ_0_0.Element) -> Bool

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,14 @@ static bool isSDKNodeEqual(SDKContext &Ctx, const SDKNode &L, const SDKNode &R)
796796
return false;
797797
if (Left->getPrintedName() == Right->getPrintedName())
798798
return true;
799-
return Left->getName() == Right->getName() &&
800-
Left->hasSameChildren(*Right);
799+
if (Ctx.checkingABI()) {
800+
// For abi checking where we don't have sugar types at all, the printed
801+
// name difference is enough to indicate these two types differ.
802+
return false;
803+
} else {
804+
return Left->getName() == Right->getName() &&
805+
Left->hasSameChildren(*Right);
806+
}
801807
}
802808

803809
case SDKNodeKind::DeclFunction: {

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void swift::ide::api::SDKNodeType::diagnose(SDKNode *Right) {
927927
}
928928

929929
void swift::ide::api::SDKNodeTypeFunc::diagnose(SDKNode *Right) {
930-
SDKNode::diagnose(Right);
930+
SDKNodeType::diagnose(Right);
931931
auto *RT = dyn_cast<SDKNodeTypeFunc>(Right);
932932
if (!RT || !shouldDiagnoseType(this))
933933
return;

0 commit comments

Comments
 (0)