Skip to content

Commit c370c4d

Browse files
authored
Merge pull request #27011 from nkcsgexi/abi-checker-cherry-pick-08-28-19
[5.1 08-28-2019] Cherry-picking recent Swift framework ABI checker enhancements
2 parents 3d28333 + e6dd201 commit c370c4d

File tree

55 files changed

+40880
-38510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+40880
-38510
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ ERROR(decl_new_witness_table_entry,none,"%0 now requires %select{|no}1 new witne
9696

9797
ERROR(new_decl_without_intro,none,"%0 is a new API without @available attribute", (StringRef))
9898

99+
ERROR(objc_name_change,none,"%0 has ObjC name change from %1 to %2", (StringRef, StringRef, StringRef))
100+
99101
#ifndef DIAG_NO_UNDEF
100102
# if defined(DIAG)
101103
# undef DIAG

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class FrontendOptions {
7676
/// binary module has already been built for use by the compiler.
7777
std::string PrebuiltModuleCachePath;
7878

79+
/// For these modules, we should prefer using Swift interface when importing them.
80+
std::vector<std::string> PreferInterfaceForModules;
81+
7982
/// Emit index data for imported serialized swift system modules.
8083
bool IndexSystemModules = false;
8184

include/swift/Frontend/ParseableInterfaceModuleLoader.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,18 @@ class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
128128
explicit ParseableInterfaceModuleLoader(
129129
ASTContext &ctx, StringRef cacheDir, StringRef prebuiltCacheDir,
130130
DependencyTracker *tracker, ModuleLoadingMode loadMode,
131+
ArrayRef<std::string> PreferInterfaceForModules,
131132
bool RemarkOnRebuildFromInterface)
132133
: SerializedModuleLoaderBase(ctx, tracker, loadMode),
133134
CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir),
134-
RemarkOnRebuildFromInterface(RemarkOnRebuildFromInterface)
135+
RemarkOnRebuildFromInterface(RemarkOnRebuildFromInterface),
136+
PreferInterfaceForModules(PreferInterfaceForModules)
135137
{}
136138

137139
std::string CacheDir;
138140
std::string PrebuiltCacheDir;
139141
bool RemarkOnRebuildFromInterface;
142+
ArrayRef<std::string> PreferInterfaceForModules;
140143

141144
std::error_code findModuleFilesInDirectory(
142145
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
@@ -150,10 +153,12 @@ class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
150153
static std::unique_ptr<ParseableInterfaceModuleLoader>
151154
create(ASTContext &ctx, StringRef cacheDir, StringRef prebuiltCacheDir,
152155
DependencyTracker *tracker, ModuleLoadingMode loadMode,
156+
ArrayRef<std::string> PreferInterfaceForModules = {},
153157
bool RemarkOnRebuildFromInterface = false) {
154158
return std::unique_ptr<ParseableInterfaceModuleLoader>(
155159
new ParseableInterfaceModuleLoader(ctx, cacheDir, prebuiltCacheDir,
156160
tracker, loadMode,
161+
PreferInterfaceForModules,
157162
RemarkOnRebuildFromInterface));
158163
}
159164

include/swift/IDE/DigesterEnums.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,22 @@ KEY_STRING(ModuleName, moduleName)
143143
KEY_STRING(SuperclassUsr, superclassUsr)
144144
KEY_STRING(EnumRawTypeName, enumRawTypeName)
145145
KEY_STRING(GenericSig, genericSig)
146+
KEY_STRING(SugaredGenericSig, sugared_genericSig)
146147
KEY_STRING(FuncSelfKind, funcSelfKind)
147148
KEY_STRING(ParamValueOwnership, paramValueOwnership)
148149
KEY_STRING(IntromacOS, intro_Macosx)
149150
KEY_STRING(IntroiOS, intro_iOS)
150151
KEY_STRING(IntrotvOS, intro_tvOS)
151152
KEY_STRING(IntrowatchOS, intro_watchOS)
152153
KEY_STRING(Introswift, intro_swift)
154+
KEY_STRING(ObjCName, objc_name)
153155

154156
KEY_STRING_ARR(SuperclassNames, superclassNames)
157+
KEY_STRING_ARR(ToolArgs, tool_arguments)
155158

156159
KEY_UINT(SelfIndex, selfIndex)
157160
KEY_UINT(FixedBinaryOrder, fixedbinaryorder)
161+
KEY_UINT(JsonFormatVer, json_format_version)
158162

159163
KEY(children)
160164
KEY(conformances)

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ bool CompilerInstance::setUpModuleLoaders() {
361361
StringRef PrebuiltModuleCachePath = FEOpts.PrebuiltModuleCachePath;
362362
auto PIML = ParseableInterfaceModuleLoader::create(
363363
*Context, ModuleCachePath, PrebuiltModuleCachePath,
364-
getDependencyTracker(), MLM, FEOpts.RemarkOnRebuildFromModuleInterface);
364+
getDependencyTracker(), MLM, FEOpts.PreferInterfaceForModules,
365+
FEOpts.RemarkOnRebuildFromModuleInterface);
365366
Context->addModuleLoader(std::move(PIML));
366367
}
367368
Context->addModuleLoader(std::move(SML));

lib/Frontend/ParseableInterfaceModuleLoader.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,11 +1425,14 @@ std::error_code ParseableInterfaceModuleLoader::findModuleFilesInDirectory(
14251425
}
14261426

14271427
// Create an instance of the Impl to do the heavy lifting.
1428+
auto ModuleName = ModuleID.first.str();
14281429
ParseableInterfaceModuleLoaderImpl Impl(
1429-
Ctx, ModPath, InPath, ModuleID.first.str(),
1430+
Ctx, ModPath, InPath, ModuleName,
14301431
CacheDir, PrebuiltCacheDir, ModuleID.second,
14311432
RemarkOnRebuildFromInterface, dependencyTracker,
1432-
LoadMode);
1433+
llvm::is_contained(PreferInterfaceForModules,
1434+
ModuleName) ?
1435+
ModuleLoadingMode::PreferParseable : LoadMode);
14331436

14341437
// Ask the impl to find us a module that we can load or give us an error
14351438
// telling us that we couldn't load it.

test/api-digester/Inputs/cake.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public protocol P1 {}
44
public protocol P2 {}
55
public protocol P3: P2, P1 {}
6+
67
@frozen
78
public struct S1: P1 {
89
public static func foo1() {}
@@ -123,3 +124,18 @@ public class PlatformIntroClass {}
123124

124125
@available(swift, introduced: 5)
125126
public class SwiftIntroClass {}
127+
128+
@objc(NewObjCClass)
129+
public class SwiftObjcClass {
130+
@objc(ObjCFool:ObjCA:ObjCB:)
131+
public func foo(a:Int, b:Int, c: Int) {}
132+
}
133+
134+
@available(iOS 10.2, tvOS 10.3, watchOS 3.4, *)
135+
@available(macOS, unavailable)
136+
public class UnavailableOnMac {}
137+
138+
@available(macOS, unavailable)
139+
extension SwiftObjcClass {
140+
public func functionUnavailableOnMac() {}
141+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,9 @@ public class Zoo {
195195
}
196196

197197
public func returnFunctionTypeOwnershipChange() -> (C1) -> () { return { _ in } }
198+
199+
@objc(OldObjCClass)
200+
public class SwiftObjcClass {
201+
@objc(OldObjCFool:OldObjCA:OldObjCB:)
202+
public func foo(a:Int, b:Int, c: Int) {}
203+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,9 @@ public class Zoo {
202202
}
203203

204204
public func returnFunctionTypeOwnershipChange() -> (__owned C1) -> () { return { _ in } }
205+
206+
@objc(NewObjCClass)
207+
public class SwiftObjcClass {
208+
@objc(NewObjCFool:NewObjCA:NewObjCB:)
209+
public func foo(a:Int, b:Int, c: Int) {}
210+
}

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11

22
/* Generic Signature Changes */
3-
cake: Func P1.P1Constraint() has generic signature change from <τ_0_0 where τ_0_0 : P1, τ_0_0 : P2> to <τ_0_0 where τ_0_0 : P1>
4-
cake: Protocol P3 has generic signature change from <τ_0_0 : P1, τ_0_0 : P2> to <τ_0_0 : P1, τ_0_0 : P4>
3+
cake: Func P1.P1Constraint() has generic signature change from <Self where Self : cake.P1, Self : cake.P2> to <Self where Self : cake.P1>
4+
cake: Protocol P3 has generic signature change from <Self : cake.P1, Self : cake.P2> to <Self : cake.P1, Self : cake.P4>
55

66
/* RawRepresentable Changes */
77

88
/* Removed Decls */
9-
Swift: Extension Int has been removed
109
cake: Accessor GlobalVarChangedToLet.Modify() has been removed
1110
cake: Accessor GlobalVarChangedToLet.Set() has been removed
1211
cake: Accessor RemoveSetters.Value.Modify() has been removed
@@ -18,6 +17,7 @@ cake: AssociatedType RequiementChanges.removedType has been removed
1817
cake: Class C3 has been removed
1918
cake: Constructor Somestruct2.init(_:) has been removed
2019
cake: Func C4.foo() has been removed
20+
cake: Func Int.IntEnhancer() has been removed
2121
cake: Func RequiementChanges.removedFunc() has been removed
2222
cake: Var RequiementChanges.removedVar has been removed
2323

@@ -27,25 +27,27 @@ cake: InfixOperator ..*.. has been changed to a PrefixOperator
2727
cake: Protocol ProtocolToEnum has been changed to a Enum
2828

2929
/* Renamed Decls */
30+
cake: Class SwiftObjcClass has ObjC name change from OldObjCClass to NewObjCClass
3031
cake: Func S1.foo5(x:y:) has been renamed to Func foo5(x:y:z:)
32+
cake: Func SwiftObjcClass.foo(a:b:c:) has ObjC name change from OldObjCFool:OldObjCA:OldObjCB: to NewObjCFool:NewObjCA:NewObjCB:
3133
cake: Struct Somestruct2 has been renamed to Struct NSSomestruct2
3234

3335
/* Type Changes */
34-
cake: Accessor Zoo.current.Get() has return type change from Cat to Dog
35-
cake: AssociatedType AssociatedTypePro.T3 has default type change from C1 to C6
36-
cake: Class TChangesFromIntToString has type witness type for AssociatedTypesProtocol.T changing from Int to String
37-
cake: Constructor S1.init(_:) has parameter 0 type change from Int to Double
38-
cake: Func C1.foo2(_:) has parameter 0 type change from Int to () -> ()
36+
cake: Accessor Zoo.current.Get() has return type change from cake.Cat to cake.Dog
37+
cake: AssociatedType AssociatedTypePro.T3 has default type change from cake.C1 to cake.C6
38+
cake: Class TChangesFromIntToString has type witness type for AssociatedTypesProtocol.T changing from Swift.Int to Swift.String
39+
cake: Constructor S1.init(_:) has parameter 0 type change from Swift.Int to Swift.Double
40+
cake: Func C1.foo2(_:) has parameter 0 type change from Swift.Int to () -> ()
3941
cake: Func C7.foo(_:_:) has removed default argument from parameter 0
4042
cake: Func C7.foo(_:_:) has removed default argument from parameter 1
4143
cake: Func EscapingFunctionType.addedEscaping(_:) has added @escaping in parameter 0
4244
cake: Func EscapingFunctionType.removedEscaping(_:) has removed @escaping in parameter 0
43-
cake: Func Somestruct2.foo1(_:) has parameter 0 type change from C3 to C1
44-
cake: Func Zoo.getCurrentAnimalInlinable() has return type change from Cat to Dog
45+
cake: Func Somestruct2.foo1(_:) has parameter 0 type change from cake.C3 to cake.C1
46+
cake: Func Zoo.getCurrentAnimalInlinable() has return type change from cake.Cat to cake.Dog
4547
cake: Func ownershipChange(_:_:) has parameter 0 changing from InOut to Default
4648
cake: Func ownershipChange(_:_:) has parameter 1 changing from Shared to Owned
47-
cake: Func returnFunctionTypeOwnershipChange() has return type change from (C1) -> () to (__owned C1) -> ()
48-
cake: Var Zoo.current has declared type change from Cat to Dog
49+
cake: Func returnFunctionTypeOwnershipChange() has return type change from (cake.C1) -> () to (__owned cake.C1) -> ()
50+
cake: Var Zoo.current has declared type change from cake.Cat to cake.Dog
4951

5052
/* Decl Attribute changes */
5153
cake: Accessor GlobalLetChangedToVar.Modify() is a new API without @available attribute
@@ -103,13 +105,13 @@ cake: Struct fixedLayoutStruct has removed conformance to P1
103105

104106
/* Protocol Requirement Change */
105107
cake: Accessor HasMutatingMethodClone.bar.Get() now requires new witness table entry
106-
cake: AssociatedType AssociatedTypePro.T1 has removed default type Int
108+
cake: AssociatedType AssociatedTypePro.T1 has removed default type Swift.Int
107109
cake: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
108110
cake: Func HasMutatingMethodClone.foo() now requires new witness table entry
109111
cake: Func RequiementChanges.addedFunc() has been added as a protocol requirement
110112
cake: Var RequiementChanges.addedVar has been added as a protocol requirement
111113

112114
/* Class Inheritance Change */
113-
cake: Class C4 has changed its super class from OldType to NewType
114-
cake: Class SubGenericClass has changed its super class from GenericClass<P1> to GenericClass<P2>
115-
cake: Class SuperClassRemoval has removed its super class C3
115+
cake: Class C4 has changed its super class from APINotesTest.OldType to APINotesTest.NewType
116+
cake: Class SubGenericClass has changed its super class from cake.GenericClass<cake.P1> to cake.GenericClass<cake.P2>
117+
cake: Class SuperClassRemoval has removed its super class cake.C3
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cake: Func FrozenKind.__derived_enum_equals(_:_:) has been removed
2+
cake: Accessor GlobalLetChangedToVar.Get() is a new API without @available attribute
3+
cake: Accessor GlobalVarChangedToLet.Get() is a new API without @available attribute
4+
cake: Accessor GlobalVarChangedToLet.Modify() is a new API without @available attribute
5+
cake: Accessor GlobalVarChangedToLet.Set() is a new API without @available attribute
6+
cake: Enum FrozenKind is now with @frozen
7+
cake: Enum IceKind is now with @frozen
8+
cake: Func FrozenKind.==(_:_:) is a new API without @available attribute
9+
cake: Var C1.CIIns1 is no longer a stored property
10+
cake: Var C1.CIIns2 is no longer a stored property
11+
cake: Var RemoveSetters.Value is no longer a stored property

test/api-digester/Outputs/Cake.txt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11

22
/* Generic Signature Changes */
3-
cake: Func P1.P1Constraint() has generic signature change from <Self where Self : P1, Self : P2> to <Self where Self : P1>
4-
cake: Protocol P3 has generic signature change from <Self : P1, Self : P2> to <Self : P1, Self : P4>
3+
cake: Func P1.P1Constraint() has generic signature change from <Self where Self : cake.P1, Self : cake.P2> to <Self where Self : cake.P1>
4+
cake: Protocol P3 has generic signature change from <Self : cake.P1, Self : cake.P2> to <Self : cake.P1, Self : cake.P4>
55

66
/* RawRepresentable Changes */
77

88
/* Removed Decls */
9-
Swift: Extension Int has been removed
109
cake: Accessor GlobalVarChangedToLet.Set() has been removed
1110
cake: Accessor RemoveSetters.Value.Set() has been removed
1211
cake: Accessor RemoveSetters.subscript(_:).Set() has been removed
1312
cake: AssociatedType RequiementChanges.removedType has been removed
1413
cake: Constructor Somestruct2.init(_:) has been removed
1514
cake: Func C4.foo() has been removed
15+
cake: Func Int.IntEnhancer() has been removed
1616
cake: Func RequiementChanges.removedFunc() has been removed
1717
cake: Var RequiementChanges.removedVar has been removed
1818

@@ -22,18 +22,20 @@ cake: InfixOperator ..*.. has been changed to a PrefixOperator
2222
cake: Protocol ProtocolToEnum has been changed to a Enum
2323

2424
/* Renamed Decls */
25+
cake: Class SwiftObjcClass has ObjC name change from OldObjCClass to NewObjCClass
2526
cake: Func S1.foo5(x:y:) has been renamed to Func foo5(x:y:z:)
27+
cake: Func SwiftObjcClass.foo(a:b:c:) has ObjC name change from OldObjCFool:OldObjCA:OldObjCB: to NewObjCFool:NewObjCA:NewObjCB:
2628
cake: Struct Somestruct2 has been renamed to Struct NSSomestruct2
2729

2830
/* Type Changes */
29-
cake: AssociatedType AssociatedTypePro.T3 has default type change from C1 to C6
30-
cake: Constructor S1.init(_:) has parameter 0 type change from Int to Double
31-
cake: Func C1.foo2(_:) has parameter 0 type change from Int to () -> ()
31+
cake: AssociatedType AssociatedTypePro.T3 has default type change from cake.C1 to cake.C6
32+
cake: Constructor S1.init(_:) has parameter 0 type change from Swift.Int to Swift.Double
33+
cake: Func C1.foo2(_:) has parameter 0 type change from Swift.Int to () -> ()
3234
cake: Func C7.foo(_:_:) has removed default argument from parameter 0
3335
cake: Func C7.foo(_:_:) has removed default argument from parameter 1
3436
cake: Func ownershipChange(_:_:) has parameter 0 changing from InOut to Default
3537
cake: Func ownershipChange(_:_:) has parameter 1 changing from Shared to Owned
36-
cake: TypeAlias TChangesFromIntToString.T has underlying type change from Int to String
38+
cake: TypeAlias TChangesFromIntToString.T has underlying type change from Swift.Int to Swift.String
3739

3840
/* Decl Attribute changes */
3941
cake: Func C1.foo1() is now not static
@@ -52,16 +54,16 @@ cake: Protocol P3 has removed inherited protocol P2
5254
cake: Struct fixedLayoutStruct has removed conformance to P1
5355

5456
/* Protocol Requirement Change */
55-
cake: AssociatedType AssociatedTypePro.T1 has removed default type Int
57+
cake: AssociatedType AssociatedTypePro.T1 has removed default type Swift.Int
5658
cake: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
5759
cake: Func RequiementChanges.addedFunc() has been added as a protocol requirement
5860
cake: Var RequiementChanges.addedVar has been added as a protocol requirement
5961
cake: Accessor ClassWithOpenMember.property.Get() is no longer open for subclassing
6062

6163
/* Class Inheritance Change */
62-
cake: Class C4 has changed its super class from OldType to NewType
63-
cake: Class SubGenericClass has changed its super class from GenericClass<P1> to GenericClass<P2>
64-
cake: Class SuperClassRemoval has removed its super class C3
64+
cake: Class C4 has changed its super class from APINotesTest.OldType to APINotesTest.NewType
65+
cake: Class SubGenericClass has changed its super class from cake.GenericClass<cake.P1> to cake.GenericClass<cake.P2>
66+
cake: Class SuperClassRemoval has removed its super class cake.C3
6567
cake: Func ClassWithOpenMember.bar() is no longer open for subclassing
6668
cake: Func ClassWithOpenMember.foo() is no longer open for subclassing
6769
cake: Var ClassWithOpenMember.property is no longer open for subclassing

test/api-digester/Outputs/apinotes-diags-3-4.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
/* Generic Signature Changes */
33

44
/* RawRepresentable Changes */
5-
APINotesTest(APINotesTest.h): TypeAlias AnimalAttributeName(NSString) is now String representable
65

76
/* Removed Decls */
7+
APINotesTest(APINotesTest.h): TypeAlias AnimalAttributeName has been removed
88

99
/* Moved Decls */
1010

1111
/* Renamed Decls */
1212
APINotesTest(APINotesTest.h): Var globalAttributeName has been renamed to Var AnimalAttributeName.globalAttributeName
1313

1414
/* Type Changes */
15-
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingAttributes(_:) has parameter 0 type change from [String : Any] to [AnimalAttributeName : Any]
16-
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingAttributesArray(_:) has parameter 0 type change from [String] to [AnimalAttributeName]
17-
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingOptionalAttributes(_:) has parameter 0 type change from [String : Any]? to [AnimalAttributeName : Any]?
18-
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingOptionalAttributesArray(_:) has parameter 0 type change from [String]? to [AnimalAttributeName]?
19-
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.animalStatusSingleAttribute(_:) has parameter 0 type change from String to AnimalAttributeName
20-
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.animalStatusSingleOptionalAttribute(_:) has parameter 0 type change from String? to AnimalAttributeName?
15+
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingAttributes(_:) has parameter 0 type change from [Swift.String : Any] to [APINotesTest.AnimalAttributeName : Any]
16+
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingAttributesArray(_:) has parameter 0 type change from [Swift.String] to [APINotesTest.AnimalAttributeName]
17+
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingOptionalAttributes(_:) has parameter 0 type change from [Swift.String : Any]? to [APINotesTest.AnimalAttributeName : Any]?
18+
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.addingOptionalAttributesArray(_:) has parameter 0 type change from [Swift.String]? to [APINotesTest.AnimalAttributeName]?
19+
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.animalStatusSingleAttribute(_:) has parameter 0 type change from Swift.String to APINotesTest.AnimalAttributeName
20+
APINotesTest(APINotesTest.h): Func AnimalStatusDescriptor.animalStatusSingleOptionalAttribute(_:) has parameter 0 type change from Swift.String? to APINotesTest.AnimalAttributeName?
2121

2222
/* Decl Attribute changes */

0 commit comments

Comments
 (0)