Skip to content

Commit 0567a9b

Browse files
committed
ABI checker: include SPI group names in ABI descriptor files
1 parent e46b5f5 commit 0567a9b

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

Diff for: include/swift/APIDigester/ModuleAnalyzerNodes.h

+2
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ class SDKNodeDecl: public SDKNode {
346346
StringRef Location;
347347
StringRef ModuleName;
348348
std::vector<DeclAttrKind> DeclAttributes;
349+
std::vector<StringRef> SPIGroups;
349350
bool IsImplicit;
350351
bool IsStatic;
351352
bool IsDeprecated;
@@ -373,6 +374,7 @@ class SDKNodeDecl: public SDKNode {
373374
StringRef getModuleName() const {return ModuleName;}
374375
StringRef getHeaderName() const;
375376
ArrayRef<DeclAttrKind> getDeclAttributes() const;
377+
ArrayRef<StringRef> getSPIGroups() const { return SPIGroups; }
376378
bool hasAttributeChange(const SDKNodeDecl &Another) const;
377379
swift::ReferenceOwnership getReferenceOwnership() const {
378380
return swift::ReferenceOwnership(ReferenceOwnership);

Diff for: include/swift/IDE/DigesterEnums.def

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ KEY_STRING(InitKind, init_kind)
162162

163163
KEY_STRING_ARR(SuperclassNames, superclassNames)
164164
KEY_STRING_ARR(ToolArgs, tool_arguments)
165+
KEY_STRING_ARR(SPIGroups, spi_group_names)
165166

166167
KEY_UINT(SelfIndex, selfIndex)
167168
KEY_UINT(FixedBinaryOrder, fixedbinaryorder)

Diff for: lib/APIDigester/ModuleAnalyzerNodes.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ SDKNodeDecl::SDKNodeDecl(SDKNodeInitInfo Info, SDKNodeKind Kind)
114114
: SDKNode(Info, Kind), DKind(Info.DKind), Usr(Info.Usr),
115115
MangledName(Info.MangledName), Loc(Info.Loc),
116116
Location(Info.Location), ModuleName(Info.ModuleName),
117-
DeclAttributes(Info.DeclAttrs), IsImplicit(Info.IsImplicit),
117+
DeclAttributes(Info.DeclAttrs),
118+
SPIGroups(Info.SPIGroups),
119+
IsImplicit(Info.IsImplicit),
118120
IsStatic(Info.IsStatic), IsDeprecated(Info.IsDeprecated),
119121
IsProtocolReq(Info.IsProtocolReq),
120122
IsOverriding(Info.IsOverriding),
@@ -1436,7 +1438,12 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, Decl *D):
14361438
IsDeprecated(D->getAttrs().getDeprecated(D->getASTContext())),
14371439
IsABIPlaceholder(isABIPlaceholderRecursive(D)),
14381440
IsFromExtension(isDeclaredInExtension(D)),
1439-
DeclAttrs(collectDeclAttributes(D)) {}
1441+
DeclAttrs(collectDeclAttributes(D)) {
1442+
// Keep track of SPI group names
1443+
for (auto id: D->getSPIGroups()) {
1444+
SPIGroups.push_back(id.str());
1445+
}
1446+
}
14401447

14411448
SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, OperatorDecl *OD):
14421449
SDKNodeInitInfo(Ctx, cast<Decl>(OD)) {
@@ -2083,6 +2090,7 @@ void SDKNodeDecl::jsonize(json::Output &out) {
20832090
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_ownership).data(), Raw);
20842091
}
20852092
output(out, KeyKind::KK_isFromExtension, IsFromExtension);
2093+
out.mapOptional(getKeyContent(Ctx, KeyKind::KK_spi_group_names).data(), SPIGroups);
20862094
}
20872095

20882096
void SDKNodeDeclAbstractFunc::jsonize(json::Output &out) {

Diff for: test/api-digester/Inputs/cake.swift

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ public func silgenNamedFunc() {}
148148

149149
@available(OSX 10.7, *)
150150
@_originallyDefinedIn(module: "Bread", OSX 10.9)
151+
@_spi(top_secret_1)
152+
@_spi(top_secret_2)
151153
public class SinkingClass {
152154
public init() {}
153155
}

Diff for: test/api-digester/Outputs/cake-abi.json

+10
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,10 @@
16561656
"usr": "s:4cake12SinkingClassCACycfc",
16571657
"mangledName": "$s5Bread12SinkingClassCACycfc",
16581658
"moduleName": "cake",
1659+
"spi_group_names": [
1660+
"top_secret_2",
1661+
"top_secret_1"
1662+
],
16591663
"init_kind": "Designated"
16601664
}
16611665
],
@@ -1665,8 +1669,14 @@
16651669
"moduleName": "cake",
16661670
"intro_Macosx": "10.7",
16671671
"declAttributes": [
1672+
"SPIAccessControl",
1673+
"SPIAccessControl",
16681674
"OriginallyDefinedIn",
16691675
"Available"
1676+
],
1677+
"spi_group_names": [
1678+
"top_secret_2",
1679+
"top_secret_1"
16701680
]
16711681
},
16721682
{

Diff for: test/api-digester/Outputs/cake.json

+10
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,10 @@
15171517
"usr": "s:4cake12SinkingClassCACycfc",
15181518
"mangledName": "$s5Bread12SinkingClassCACycfc",
15191519
"moduleName": "cake",
1520+
"spi_group_names": [
1521+
"top_secret_2",
1522+
"top_secret_1"
1523+
],
15201524
"init_kind": "Designated"
15211525
}
15221526
],
@@ -1526,8 +1530,14 @@
15261530
"moduleName": "cake",
15271531
"intro_Macosx": "10.7",
15281532
"declAttributes": [
1533+
"SPIAccessControl",
1534+
"SPIAccessControl",
15291535
"OriginallyDefinedIn",
15301536
"Available"
1537+
],
1538+
"spi_group_names": [
1539+
"top_secret_2",
1540+
"top_secret_1"
15311541
]
15321542
},
15331543
{

0 commit comments

Comments
 (0)