Skip to content

Commit 0eb756f

Browse files
committed
swift-module-digester: serialize whether a declaration is implicit.
1 parent fda107c commit 0eb756f

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

include/swift/IDE/DigesterEnums.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ KEY(throwing)
100100
KEY(mutating)
101101
KEY(static)
102102
KEY(deprecated)
103+
KEY(implicit)
103104
KEY(typeAttributes)
104105
KEY(declAttributes)
105106
KEY(declKind)

test/api-digester/Outputs/cake-abi.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"usr": "s:4cake2S1VACycfc",
9696
"location": "",
9797
"moduleName": "cake",
98+
"implicit": true,
9899
"children": [
99100
{
100101
"kind": "TypeNominal",
@@ -125,6 +126,7 @@
125126
"location": "",
126127
"moduleName": "cake",
127128
"genericSig": "<τ_0_0, τ_0_1, τ_0_2>",
129+
"implicit": true,
128130
"children": [
129131
{
130132
"kind": "TypeNominal",
@@ -241,6 +243,7 @@
241243
"usr": "s:4cake2C1C3InsACSgXwvg",
242244
"location": "",
243245
"moduleName": "cake",
246+
"implicit": true,
244247
"declAttributes": [
245248
"Transparent"
246249
],
@@ -269,6 +272,7 @@
269272
"usr": "s:4cake2C1C3InsACSgXwvs",
270273
"location": "",
271274
"moduleName": "cake",
275+
"implicit": true,
272276
"declAttributes": [
273277
"Transparent"
274278
],
@@ -323,6 +327,7 @@
323327
"usr": "s:4cake2C1C4Ins2ACXovg",
324328
"location": "",
325329
"moduleName": "cake",
330+
"implicit": true,
326331
"declAttributes": [
327332
"Transparent"
328333
],
@@ -343,6 +348,7 @@
343348
"usr": "s:4cake2C1C4Ins2ACXovs",
344349
"location": "",
345350
"moduleName": "cake",
351+
"implicit": true,
346352
"declAttributes": [
347353
"Transparent"
348354
],
@@ -370,6 +376,7 @@
370376
"usr": "s:4cake2C1CACycfc",
371377
"location": "",
372378
"moduleName": "cake",
379+
"implicit": true,
373380
"children": [
374381
{
375382
"kind": "TypeNominal",
@@ -499,6 +506,7 @@
499506
"usr": "s:4cake6NumberO8RawValuea",
500507
"location": "",
501508
"moduleName": "cake",
509+
"implicit": true,
502510
"children": [
503511
{
504512
"kind": "TypeNominal",
@@ -516,6 +524,7 @@
516524
"usr": "s:4cake6NumberO9hashValueSivp",
517525
"location": "",
518526
"moduleName": "cake",
527+
"implicit": true,
519528
"children": [
520529
{
521530
"kind": "TypeNominal",
@@ -531,6 +540,7 @@
531540
"usr": "s:4cake6NumberO9hashValueSivg",
532541
"location": "",
533542
"moduleName": "cake",
543+
"implicit": true,
534544
"children": [
535545
{
536546
"kind": "TypeNominal",
@@ -550,6 +560,7 @@
550560
"usr": "s:4cake6NumberO4hash4intoys6HasherVz_tF",
551561
"location": "",
552562
"moduleName": "cake",
563+
"implicit": true,
553564
"children": [
554565
{
555566
"kind": "TypeNominal",
@@ -572,6 +583,7 @@
572583
"usr": "s:4cake6NumberO8rawValueACSgSi_tcfc",
573584
"location": "",
574585
"moduleName": "cake",
586+
"implicit": true,
575587
"declAttributes": [
576588
"Inlinable"
577589
],
@@ -606,6 +618,7 @@
606618
"usr": "s:4cake6NumberO8rawValueSivp",
607619
"location": "",
608620
"moduleName": "cake",
621+
"implicit": true,
609622
"children": [
610623
{
611624
"kind": "TypeNominal",
@@ -621,6 +634,7 @@
621634
"usr": "s:4cake6NumberO8rawValueSivg",
622635
"location": "",
623636
"moduleName": "cake",
637+
"implicit": true,
624638
"declAttributes": [
625639
"Inlinable"
626640
],

test/api-digester/Outputs/cake.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"usr": "s:4cake2S1VACycfc",
103103
"location": "",
104104
"moduleName": "cake",
105+
"implicit": true,
105106
"children": [
106107
{
107108
"kind": "TypeNominal",
@@ -132,6 +133,7 @@
132133
"location": "",
133134
"moduleName": "cake",
134135
"genericSig": "<T1, T2, T3>",
136+
"implicit": true,
135137
"children": [
136138
{
137139
"kind": "TypeNominal",
@@ -248,6 +250,7 @@
248250
"usr": "s:4cake2C1C3InsACSgXwvg",
249251
"location": "",
250252
"moduleName": "cake",
253+
"implicit": true,
251254
"declAttributes": [
252255
"Transparent"
253256
],
@@ -276,6 +279,7 @@
276279
"usr": "s:4cake2C1C3InsACSgXwvs",
277280
"location": "",
278281
"moduleName": "cake",
282+
"implicit": true,
279283
"declAttributes": [
280284
"Transparent"
281285
],
@@ -330,6 +334,7 @@
330334
"usr": "s:4cake2C1C4Ins2ACXovg",
331335
"location": "",
332336
"moduleName": "cake",
337+
"implicit": true,
333338
"declAttributes": [
334339
"Transparent"
335340
],
@@ -350,6 +355,7 @@
350355
"usr": "s:4cake2C1C4Ins2ACXovs",
351356
"location": "",
352357
"moduleName": "cake",
358+
"implicit": true,
353359
"declAttributes": [
354360
"Transparent"
355361
],
@@ -377,6 +383,7 @@
377383
"usr": "s:4cake2C1CACycfc",
378384
"location": "",
379385
"moduleName": "cake",
386+
"implicit": true,
380387
"children": [
381388
{
382389
"kind": "TypeNominal",
@@ -513,6 +520,7 @@
513520
"usr": "s:4cake6NumberO8RawValuea",
514521
"location": "",
515522
"moduleName": "cake",
523+
"implicit": true,
516524
"children": [
517525
{
518526
"kind": "TypeNominal",
@@ -530,6 +538,7 @@
530538
"usr": "s:4cake6NumberO9hashValueSivp",
531539
"location": "",
532540
"moduleName": "cake",
541+
"implicit": true,
533542
"children": [
534543
{
535544
"kind": "TypeNominal",
@@ -545,6 +554,7 @@
545554
"usr": "s:4cake6NumberO9hashValueSivg",
546555
"location": "",
547556
"moduleName": "cake",
557+
"implicit": true,
548558
"children": [
549559
{
550560
"kind": "TypeNominal",
@@ -564,6 +574,7 @@
564574
"usr": "s:4cake6NumberO4hash4intoys6HasherVz_tF",
565575
"location": "",
566576
"moduleName": "cake",
577+
"implicit": true,
567578
"children": [
568579
{
569580
"kind": "TypeNominal",
@@ -586,6 +597,7 @@
586597
"usr": "s:4cake6NumberO8rawValueACSgSi_tcfc",
587598
"location": "",
588599
"moduleName": "cake",
600+
"implicit": true,
589601
"declAttributes": [
590602
"Inlinable"
591603
],
@@ -620,6 +632,7 @@
620632
"usr": "s:4cake6NumberO8rawValueSivp",
621633
"location": "",
622634
"moduleName": "cake",
635+
"implicit": true,
623636
"children": [
624637
{
625638
"kind": "TypeNominal",
@@ -635,6 +648,7 @@
635648
"usr": "s:4cake6NumberO8rawValueSivg",
636649
"location": "",
637650
"moduleName": "cake",
651+
"implicit": true,
638652
"declAttributes": [
639653
"Inlinable"
640654
],

test/api-digester/Outputs/clang-module-dump.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"usr": "c:objc(cs)NSObject(im)init",
5555
"location": "",
5656
"moduleName": "Foo",
57+
"implicit": true,
5758
"declAttributes": [
5859
"Override",
5960
"ObjC"

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct swift::ide::api::SDKNodeInitInfo {
4242
StringRef USR;
4343
StringRef Location;
4444
StringRef ModuleName;
45+
bool IsImplicit = false;
4546
bool IsThrowing = false;
4647
bool IsMutating = false;
4748
bool IsStatic = false;
@@ -81,8 +82,8 @@ SDKNodeRoot::SDKNodeRoot(SDKNodeInitInfo Info): SDKNode(Info, SDKNodeKind::Root)
8182
SDKNodeDecl::SDKNodeDecl(SDKNodeInitInfo Info, SDKNodeKind Kind)
8283
: SDKNode(Info, Kind), DKind(Info.DKind), Usr(Info.USR),
8384
Location(Info.Location), ModuleName(Info.ModuleName),
84-
DeclAttributes(Info.DeclAttrs), IsStatic(Info.IsStatic),
85-
IsDeprecated(Info.IsDeprecated),
85+
DeclAttributes(Info.DeclAttrs), IsImplicit(Info.IsImplicit),
86+
IsStatic(Info.IsStatic), IsDeprecated(Info.IsDeprecated),
8687
ReferenceOwnership(uint8_t(Info.ReferenceOwnership)),
8788
GenericSig(Info.GenericSig) {}
8889

@@ -555,6 +556,9 @@ SDKNode* SDKNode::constructSDKNode(SDKContext &Ctx,
555556
case KeyKind::KK_deprecated:
556557
Info.IsDeprecated = true;
557558
break;
559+
case KeyKind::KK_implicit:
560+
Info.IsImplicit = true;
561+
break;
558562
case KeyKind::KK_ownership:
559563
Info.ReferenceOwnership =
560564
swift::ReferenceOwnership(getAsInt(Pair.getValue()));
@@ -921,6 +925,7 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, ValueDecl *VD)
921925
PrintedName(getPrintedName(Ctx, VD)), DKind(VD->getKind()),
922926
USR(calculateUsr(Ctx, VD)), Location(calculateLocation(Ctx, VD)),
923927
ModuleName(VD->getModuleContext()->getName().str()),
928+
IsImplicit(VD->isImplicit()),
924929
IsThrowing(isFuncThrowing(VD)), IsMutating(isFuncMutating(VD)),
925930
IsStatic(VD->isStatic()),
926931
IsDeprecated(VD->getAttrs().getDeprecated(VD->getASTContext())),
@@ -1300,6 +1305,9 @@ struct ObjectTraits<SDKNode *> {
13001305
if (bool isDeprecated = D->isDeprecated())
13011306
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_deprecated).data(),
13021307
isDeprecated);
1308+
if (bool isImplicit = D->isImplicit())
1309+
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_implicit).data(),
1310+
isImplicit);
13031311
if (auto F = dyn_cast<SDKNodeDeclAbstractFunc>(value)) {
13041312
if (bool isThrowing = F->isThrowing())
13051313
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_throwing).data(),

tools/swift-api-digester/ModuleAnalyzerNodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class SDKNodeDecl: public SDKNode {
275275
StringRef Location;
276276
StringRef ModuleName;
277277
std::vector<DeclAttrKind> DeclAttributes;
278+
bool IsImplicit;
278279
bool IsStatic;
279280
bool IsDeprecated;
280281
uint8_t ReferenceOwnership;
@@ -301,6 +302,7 @@ class SDKNodeDecl: public SDKNode {
301302
bool isSDKPrivate() const;
302303
bool isDeprecated() const { return IsDeprecated; };
303304
bool hasDeclAttribute(DeclAttrKind DAKind) const;
305+
bool isImplicit() const { return IsImplicit; };
304306
bool isStatic() const { return IsStatic; };
305307
StringRef getGenericSignature() const { return GenericSig; }
306308
StringRef getScreenInfo() const;

0 commit comments

Comments
 (0)