Skip to content

Commit 4448a22

Browse files
committed
ABI-checker: include Swift symbols only when ABI checking is enabled
ABI checking logics are largely Swift-specific, so we should exclude symbols from the underlying Clang module. rdar://64373983
1 parent f159175 commit 4448a22

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ cake: InfixOperator ..*.. has been changed to a PrefixOperator
2626
cake: Protocol ProtocolToEnum has been changed to a Enum
2727

2828
/* Renamed Decls */
29-
cake: Class SwiftObjcClass has ObjC name change from OldObjCClass to NewObjCClass
3029
cake: Func S1.foo5(x:y:) has been renamed to Func foo5(x:y:z:)
31-
cake: Func SwiftObjcClass.foo(a:b:c:) has ObjC name change from OldObjCFool:OldObjCA:OldObjCB: to NewObjCFool:NewObjCA:NewObjCB:
3230
cake: Struct Somestruct2 has been renamed to Struct NSSomestruct2
3331

3432
/* Type Changes */
@@ -54,15 +52,13 @@ cake: Accessor GlobalLetChangedToVar.Set() is a new API without @available attri
5452
cake: Accessor fixedLayoutStruct2.BecomeFixedBinaryOrder.Modify() is a new API without @available attribute
5553
cake: Accessor fixedLayoutStruct2.BecomeFixedBinaryOrder.Set() is a new API without @available attribute
5654
cake: Class C0 is a new API without @available attribute
57-
cake: Class C5 is now without @objc
5855
cake: Class C8 is a new API without @available attribute
5956
cake: Constructor C1.init(_:) is a new API without @available attribute
6057
cake: Constructor ClassWithMissingDesignatedInits.init() is a new API without @available attribute
6158
cake: Constructor SubclassWithMissingDesignatedInits.init() is a new API without @available attribute
6259
cake: Enum IceKind is now without @frozen
6360
cake: EnumElement FrozenKind.AddedCase is a new API without @available attribute
6461
cake: Func C1.foo1() is now not static
65-
cake: Func C5.dy_foo() is now with dynamic
6662
cake: Func FinalFuncContainer.NewFinalFunc() is now with final
6763
cake: Func FinalFuncContainer.NoLongerFinalFunc() is now without final
6864
cake: Func Float.floatHigher() is a new API without @available attribute
@@ -94,8 +90,6 @@ cake: Var fixedLayoutStruct2.NoLongerWithFixedBinaryOrder is no longer a stored
9490
/* Protocol Conformance Change */
9591
cake: Class C7 has added a conformance to an existing protocol P1
9692
cake: Class SuperClassChange has added a conformance to an existing protocol P1
97-
cake: Func ObjCProtocol.addOptional() is now an optional requirement
98-
cake: Func ObjCProtocol.removeOptional() is no longer an optional requirement
9993
cake: Protocol P3 has added inherited protocol P4
10094
cake: Protocol P3 has removed inherited protocol P2
10195
cake: Struct fixedLayoutStruct has added a conformance to an existing protocol P2
@@ -110,7 +104,6 @@ cake: Func RequiementChanges.addedFunc() has been added as a protocol requiremen
110104
cake: Var RequiementChanges.addedVar has been added as a protocol requirement
111105

112106
/* Class Inheritance Change */
113-
cake: Class C4 has changed its super class from APINotesTest.OldType to APINotesTest.NewType
114107
cake: Class SubGenericClass has changed its super class from cake.GenericClass<cake.P1> to cake.GenericClass<cake.P2>
115108
cake: Class SuperClassRemoval has removed its super class cake.C3
116109
cake: Class SuperClassRemoval no longer inherits convenience inits from its superclass

test/api-digester/compare-dump-abi.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,5 @@
1818
// RUN: not %api-digester -diagnose-sdk -print-module -baseline-dir %t.baseline -module cake -I %t.mod2 -I %S/Inputs/APINotesLeft -module-cache-path %t.module-cache %clang-importer-sdk-nosource -abi -o %t.result -compiler-style-diags 2> %t.abi.compiler.diags
1919
// RUN: %FileCheck %s < %t.abi.compiler.diags
2020

21-
// CHECK: cake_current/cake.swift:31:14: error: cake: Class C4 has changed its super class from APINotesTest.OldType to APINotesTest.NewType
22-
// CHECK: cake_current/cake.swift:33:14: error: cake: Class C5 is now without @objc
23-
// CHECK: cake_current/cake.swift:35:23: error: cake: Func C5.dy_foo() is now with dynamic
2421
// CHECK: cake_current/cake.swift:39:15: error: cake: Struct C6 is now with @frozen
2522
// CHECK: cake_current/cake.swift:41:13: error: cake: Enum IceKind is now without @frozen

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ SwiftDeclCollector::constructInitNode(ConstructorDecl *CD) {
15731573
bool swift::ide::api::
15741574
SDKContext::shouldIgnore(Decl *D, const Decl* Parent) const {
15751575
// Exclude all clang nodes if we're comparing Swift decls specifically.
1576+
// FIXME: isFromClang also excludes Swift decls with @objc. We should allow those.
15761577
if (Opts.SwiftOnly && isFromClang(D)) {
15771578
return true;
15781579
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2653,7 +2653,9 @@ static CheckerOptions getCheckOpts(int argc, char *argv[]) {
26532653
Opts.AbortOnModuleLoadFailure = options::AbortOnModuleLoadFailure;
26542654
Opts.LocationFilter = options::LocationFilter;
26552655
Opts.PrintModule = options::PrintModule;
2656-
Opts.SwiftOnly = options::SwiftOnly;
2656+
// When ABI checking is enabled, we should only include Swift symbols because
2657+
// the checking logics are language-specific.
2658+
Opts.SwiftOnly = options::Abi || options::SwiftOnly;
26572659
Opts.SkipOSCheck = options::DisableOSChecks;
26582660
for (int i = 1; i < argc; ++i)
26592661
Opts.ToolArgs.push_back(argv[i]);

0 commit comments

Comments
 (0)