Skip to content

Commit 41ea927

Browse files
authored
Merge pull request swiftlang#33666 from nkcsgexi/67883661
ABIChecker: exclude decls with the @_alwaysEmitIntoClient attribute
2 parents ce2377d + 1a44db3 commit 41ea927

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

test/api-digester/Inputs/cake.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,6 @@ public class UnavailableOnMac {}
139139
extension SwiftObjcClass {
140140
public func functionUnavailableOnMac() {}
141141
}
142+
143+
@_alwaysEmitIntoClient
144+
public func emitIntoClientFunc() {}

test/api-digester/Outputs/cake.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,25 @@
13401340
],
13411341
"hasMissingDesignatedInitializers": true
13421342
},
1343+
{
1344+
"kind": "Function",
1345+
"name": "emitIntoClientFunc",
1346+
"printedName": "emitIntoClientFunc()",
1347+
"children": [
1348+
{
1349+
"kind": "TypeNominal",
1350+
"name": "Void",
1351+
"printedName": "()"
1352+
}
1353+
],
1354+
"declKind": "Func",
1355+
"usr": "s:4cake18emitIntoClientFuncyyF",
1356+
"moduleName": "cake",
1357+
"declAttributes": [
1358+
"AlwaysEmitIntoClient"
1359+
],
1360+
"funcSelfKind": "NonMutating"
1361+
},
13431362
{
13441363
"kind": "TypeDecl",
13451364
"name": "Int",

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,11 @@ SDKContext::shouldIgnore(Decl *D, const Decl* Parent) const {
16031603
if (isa<TypeAliasDecl>(VD))
16041604
return true;
16051605
}
1606+
// Exclude decls with @_alwaysEmitIntoClient if we are checking ABI.
1607+
// These decls are considered effectively public because they are usable
1608+
// from inline, so we have to manually exclude them here.
1609+
if (D->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>())
1610+
return true;
16061611
} else {
16071612
if (D->isPrivateStdlibDecl(false))
16081613
return true;

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,17 @@ void swift::ide::api::SDKNodeTypeFunc::diagnose(SDKNode *Right) {
10571057
}
10581058

10591059
namespace {
1060+
static void diagnoseRemovedDecl(const SDKNodeDecl *D) {
1061+
if (D->getSDKContext().checkingABI()) {
1062+
// Don't complain about removing @_alwaysEmitIntoClient if we are checking ABI.
1063+
// We shouldn't include these decls in the ABI baseline file. This line is
1064+
// added so the checker is backward compatible.
1065+
if (D->hasDeclAttribute(DeclAttrKind::DAK_AlwaysEmitIntoClient))
1066+
return;
1067+
}
1068+
D->emitDiag(SourceLoc(), diag::removed_decl, D->isDeprecated());
1069+
}
1070+
10601071
// This is first pass on two given SDKNode trees. This pass removes the common part
10611072
// of two versions of SDK, leaving only the changed part.
10621073
class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
@@ -1241,7 +1252,7 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
12411252
TD->isProtocol());
12421253
}
12431254
if (auto *Acc = dyn_cast<SDKNodeDeclAccessor>(Left)) {
1244-
Acc->emitDiag(SourceLoc(), diag::removed_decl, Acc->isDeprecated());
1255+
diagnoseRemovedDecl(Acc);
12451256
}
12461257
return;
12471258
case NodeMatchReason::FuncToProperty:
@@ -2084,7 +2095,7 @@ static bool diagnoseRemovedExtensionMembers(const SDKNode *Node) {
20842095
if (DT->isExtension()) {
20852096
for (auto *C: DT->getChildren()) {
20862097
auto *MD = cast<SDKNodeDecl>(C);
2087-
MD->emitDiag(SourceLoc(), diag::removed_decl, MD->isDeprecated());
2098+
diagnoseRemovedDecl(MD);
20882099
}
20892100
return true;
20902101
}
@@ -2161,7 +2172,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
21612172
}
21622173
bool handled = diagnoseRemovedExtensionMembers(Node);
21632174
if (!handled)
2164-
Node->emitDiag(SourceLoc(), diag::removed_decl, Node->isDeprecated());
2175+
diagnoseRemovedDecl(Node);
21652176
return;
21662177
}
21672178
case NodeAnnotation::Rename: {

0 commit comments

Comments
 (0)