Skip to content

Commit 3121af2

Browse files
authored
swift-api-digester: keep track of all decl attribute kinds in module dump. (#18473)
The tool should use decl attribute kinds from AST rather than defining its own list of attributes. Thus we can keep track of all attributes kinds rather than the selected ones.
1 parent b06c636 commit 3121af2

File tree

7 files changed

+86050
-61857
lines changed

7 files changed

+86050
-61857
lines changed

include/swift/IDE/DigesterEnums.def

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#define NODE_ANNOTATION_CHANGE_KIND(NAME) NODE_ANNOTATION(NAME)
1111
#endif
1212

13-
#ifndef DECL_ATTR
14-
#define DECL_ATTR(NAME)
15-
#endif
16-
1713
#ifndef KEY
1814
#define KEY(NAME)
1915
#endif
@@ -96,9 +92,6 @@ NODE_ANNOTATION_CHANGE_KIND(Rename)
9692
// Keep type rewritten the last one.
9793
NODE_ANNOTATION_CHANGE_KIND(TypeRewritten)
9894

99-
DECL_ATTR(deprecated)
100-
DECL_ATTR(fixedLayout)
101-
10295
KEY(kind)
10396
KEY(name)
10497
KEY(selfIndex)
@@ -110,6 +103,7 @@ KEY(moduleName)
110103
KEY(throwing)
111104
KEY(mutating)
112105
KEY(static)
106+
KEY(deprecated)
113107
KEY(typeAttributes)
114108
KEY(declAttributes)
115109
KEY(declKind)
@@ -183,7 +177,6 @@ SPECIAL_CASE_ID(UIApplicationMain)
183177
#undef KNOWN_TYPE
184178
#undef KNOWN_PROTOCOL
185179
#undef KEY
186-
#undef DECL_ATTR
187180
#undef NODE_ANNOTATION_CHANGE_KIND
188181
#undef NODE_ANNOTATION
189182
#undef NODE_KIND

test/api-digester/Outputs/cake.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"P2"
3535
],
3636
"declAttributes": [
37-
"fixedLayout"
37+
"FixedLayout"
3838
],
3939
"children": [
4040
{
@@ -231,6 +231,9 @@
231231
"usr": "s:4cake2C1C3InsACSgXwvp",
232232
"location": "",
233233
"moduleName": "cake",
234+
"declAttributes": [
235+
"ReferenceOwnership"
236+
],
234237
"ownership": 1,
235238
"children": [
236239
{
@@ -246,6 +249,9 @@
246249
"usr": "s:4cake2C1C3InsACSgXwvg",
247250
"location": "",
248251
"moduleName": "cake",
252+
"declAttributes": [
253+
"Transparent"
254+
],
249255
"children": [
250256
{
251257
"kind": "TypeNominal",
@@ -271,6 +277,9 @@
271277
"usr": "s:4cake2C1C3InsACSgXwvs",
272278
"location": "",
273279
"moduleName": "cake",
280+
"declAttributes": [
281+
"Transparent"
282+
],
274283
"children": [
275284
{
276285
"kind": "TypeNominal",
@@ -303,6 +312,9 @@
303312
"usr": "s:4cake2C1C4Ins2ACXovp",
304313
"location": "",
305314
"moduleName": "cake",
315+
"declAttributes": [
316+
"ReferenceOwnership"
317+
],
306318
"ownership": 2,
307319
"children": [
308320
{
@@ -318,6 +330,9 @@
318330
"usr": "s:4cake2C1C4Ins2ACXovg",
319331
"location": "",
320332
"moduleName": "cake",
333+
"declAttributes": [
334+
"Transparent"
335+
],
321336
"children": [
322337
{
323338
"kind": "TypeNominal",
@@ -335,6 +350,9 @@
335350
"usr": "s:4cake2C1C4Ins2ACXovs",
336351
"location": "",
337352
"moduleName": "cake",
353+
"declAttributes": [
354+
"Transparent"
355+
],
338356
"children": [
339357
{
340358
"kind": "TypeNominal",
@@ -561,6 +579,9 @@
561579
"usr": "s:4cake6NumberO8rawValueACSgSi_tcfc",
562580
"location": "",
563581
"moduleName": "cake",
582+
"declAttributes": [
583+
"Inlinable"
584+
],
564585
"children": [
565586
{
566587
"kind": "TypeNominal",
@@ -607,6 +628,9 @@
607628
"usr": "s:4cake6NumberO8rawValueSivg",
608629
"location": "",
609630
"moduleName": "cake",
631+
"declAttributes": [
632+
"Inlinable"
633+
],
610634
"children": [
611635
{
612636
"kind": "TypeNominal",
@@ -687,7 +711,7 @@
687711
"CVarArg"
688712
],
689713
"declAttributes": [
690-
"fixedLayout"
714+
"FixedLayout"
691715
],
692716
"children": [
693717
{

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"ObjcProt",
1717
"NSObjectProtocol"
1818
],
19+
"declAttributes": [
20+
"ObjC"
21+
],
1922
"children": [
2023
{
2124
"kind": "Function",
@@ -25,6 +28,9 @@
2528
"usr": "c:objc(cs)ClangInterface(im)someFunction",
2629
"location": "",
2730
"moduleName": "Foo",
31+
"declAttributes": [
32+
"ObjC"
33+
],
2834
"children": [
2935
{
3036
"kind": "TypeNameAlias",
@@ -48,6 +54,10 @@
4854
"usr": "c:objc(cs)NSObject(im)init",
4955
"location": "",
5056
"moduleName": "Foo",
57+
"declAttributes": [
58+
"Override",
59+
"ObjC"
60+
],
5161
"children": [
5262
{
5363
"kind": "TypeNominal",
@@ -67,6 +77,9 @@
6777
"usr": "c:objc(pl)ObjcProt",
6878
"location": "",
6979
"moduleName": "Foo",
80+
"declAttributes": [
81+
"ObjC"
82+
],
7083
"children": [
7184
{
7285
"kind": "Function",
@@ -76,6 +89,9 @@
7689
"usr": "c:objc(pl)ObjcProt(im)someFunctionFromProt",
7790
"location": "",
7891
"moduleName": "Foo",
92+
"declAttributes": [
93+
"ObjC"
94+
],
7995
"children": [
8096
{
8197
"kind": "TypeNameAlias",

test/api-digester/source-stability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
// RUN: %api-digester -diagnose-sdk -input-paths %S/stdlib-stable.json -input-paths %t.tmp/current-stdlib.json >> %t.tmp/changes.txt
66
// RUN: %clang -E -P -x c %S/source-stability.swift.expected -o - | sed '/^\s*$/d' > %t.tmp/source-stability.swift.expected
77
// RUN: %clang -E -P -x c %t.tmp/changes.txt -o - | sed '/^\s*$/d' > %t.tmp/changes.txt.tmp
8-
// RUN: diff -u %t.tmp/source-stability.swift.expected %t.tmp/changes.txt.tmp ; rm -rf %S/tmp
8+
// RUN: diff -u %t.tmp/source-stability.swift.expected %t.tmp/changes.txt.tmp

0 commit comments

Comments
 (0)