|
42 | 42 | DECL_ATTR_ALIAS(SPELLING, CLASS)
|
43 | 43 | #endif
|
44 | 44 |
|
| 45 | +// A type attribute that is both a simple type attribute and a |
| 46 | +// SIL type attribute (see below). Delegates to SIL_TYPE_ATTR if that |
| 47 | +// is set and SIMPLE_TYPE_ATTR is not; otherwise delegates to SIMPLE_TYPE_ATTR. |
| 48 | +#ifndef SIMPLE_SIL_TYPE_ATTR |
| 49 | +#ifdef SIL_TYPE_ATTR |
| 50 | +#ifdef SIMPLE_TYPE_ATTR |
| 51 | +#error ambiguous delegation, must set SIMPLE_SIL_TYPE_ATTR explicitly |
| 52 | +#else |
| 53 | +#define SIMPLE_SIL_TYPE_ATTR(SPELLING, CLASS) SIL_TYPE_ATTR(SPELLING, CLASS) |
| 54 | +#endif |
| 55 | +#else |
| 56 | +#define SIMPLE_SIL_TYPE_ATTR(SPELLING, CLASS) SIMPLE_TYPE_ATTR(SPELLING, CLASS) |
| 57 | +#endif |
| 58 | +#endif |
| 59 | + |
| 60 | +// Any kind of type attribute. |
45 | 61 | #ifndef TYPE_ATTR
|
46 |
| -#define TYPE_ATTR(X) |
| 62 | +#define TYPE_ATTR(SPELLING, CLASS) |
47 | 63 | #endif
|
48 | 64 |
|
| 65 | +// A type attribute that is only valid in SIL mode. Usually this means |
| 66 | +// that it's only valid in lowered types, but sometimes SIL files |
| 67 | +// also allow things in formal types that aren't normally expressible. |
| 68 | +#ifndef SIL_TYPE_ATTR |
| 69 | +#define SIL_TYPE_ATTR(SPELLING, CLASS) TYPE_ATTR(SPELLING, CLASS) |
| 70 | +#endif |
| 71 | + |
| 72 | +// A type attribute that's always just spelled `@identifier` in source. |
| 73 | +#ifndef SIMPLE_TYPE_ATTR |
| 74 | +#define SIMPLE_TYPE_ATTR(SPELLING, CLASS) TYPE_ATTR(SPELLING, CLASS) |
| 75 | +#endif |
| 76 | + |
| 77 | + |
49 | 78 | // Type attributes
|
50 |
| -TYPE_ATTR(autoclosure) |
51 |
| -TYPE_ATTR(convention) |
52 |
| -TYPE_ATTR(noescape) |
53 |
| -TYPE_ATTR(escaping) |
54 |
| -TYPE_ATTR(differentiable) |
55 |
| -TYPE_ATTR(noDerivative) |
56 |
| -TYPE_ATTR(async) |
57 |
| -TYPE_ATTR(Sendable) |
58 |
| -TYPE_ATTR(retroactive) |
59 |
| -TYPE_ATTR(unchecked) |
60 |
| -TYPE_ATTR(preconcurrency) |
61 |
| -TYPE_ATTR(_local) |
62 |
| -TYPE_ATTR(_noMetadata) |
63 |
| -TYPE_ATTR(_opaqueReturnTypeOf) |
| 79 | +SIMPLE_TYPE_ATTR(autoclosure, Autoclosure) |
| 80 | +TYPE_ATTR(convention, Convention) |
| 81 | +SIMPLE_TYPE_ATTR(noescape, NoEscape) |
| 82 | +SIMPLE_TYPE_ATTR(escaping, Escaping) |
| 83 | +TYPE_ATTR(differentiable, Differentiable) |
| 84 | +SIMPLE_TYPE_ATTR(noDerivative, NoDerivative) |
| 85 | +SIMPLE_TYPE_ATTR(async, Async) |
| 86 | +SIMPLE_TYPE_ATTR(Sendable, Sendable) |
| 87 | +SIMPLE_TYPE_ATTR(retroactive, Retroactive) |
| 88 | +SIMPLE_TYPE_ATTR(unchecked, Unchecked) |
| 89 | +SIMPLE_TYPE_ATTR(preconcurrency, Preconcurrency) |
| 90 | +SIMPLE_TYPE_ATTR(_local, Local) |
| 91 | +SIMPLE_TYPE_ATTR(_noMetadata, NoMetadata) |
| 92 | +TYPE_ATTR(_opaqueReturnTypeOf, OpaqueReturnTypeOf) |
64 | 93 |
|
65 | 94 | // SIL-specific attributes
|
66 |
| -TYPE_ATTR(block_storage) |
67 |
| -TYPE_ATTR(box) |
68 |
| -TYPE_ATTR(dynamic_self) |
69 |
| -#define REF_STORAGE(Name, name, ...) TYPE_ATTR(sil_##name) |
| 95 | +SIMPLE_SIL_TYPE_ATTR(block_storage, BlockStorage) |
| 96 | +SIMPLE_SIL_TYPE_ATTR(box, Box) |
| 97 | +SIMPLE_SIL_TYPE_ATTR(dynamic_self, DynamicSelf) |
| 98 | +#define REF_STORAGE(Name, name, ...) SIMPLE_TYPE_ATTR(sil_##name, SIL##Name) |
70 | 99 | #include "swift/AST/ReferenceStorage.def"
|
71 |
| -TYPE_ATTR(error) |
72 |
| -TYPE_ATTR(error_indirect) |
73 |
| -TYPE_ATTR(error_unowned) |
74 |
| -TYPE_ATTR(out) |
75 |
| -TYPE_ATTR(direct) |
76 |
| -TYPE_ATTR(in) |
77 |
| -TYPE_ATTR(inout) |
78 |
| -TYPE_ATTR(inout_aliasable) |
79 |
| -TYPE_ATTR(in_guaranteed) |
80 |
| -TYPE_ATTR(in_constant) |
81 |
| -TYPE_ATTR(pack_owned) |
82 |
| -TYPE_ATTR(pack_guaranteed) |
83 |
| -TYPE_ATTR(pack_inout) |
84 |
| -TYPE_ATTR(pack_out) |
85 |
| -TYPE_ATTR(owned) |
86 |
| -TYPE_ATTR(unowned_inner_pointer) |
87 |
| -TYPE_ATTR(guaranteed) |
88 |
| -TYPE_ATTR(autoreleased) |
89 |
| -TYPE_ATTR(callee_owned) |
90 |
| -TYPE_ATTR(callee_guaranteed) |
91 |
| -TYPE_ATTR(objc_metatype) |
92 |
| -TYPE_ATTR(opened) |
93 |
| -TYPE_ATTR(pack_element) |
94 |
| -TYPE_ATTR(pseudogeneric) |
95 |
| -TYPE_ATTR(unimplementable) |
96 |
| -TYPE_ATTR(yields) |
97 |
| -TYPE_ATTR(yield_once) |
98 |
| -TYPE_ATTR(yield_many) |
99 |
| -TYPE_ATTR(captures_generics) |
| 100 | +SIMPLE_SIL_TYPE_ATTR(error, Error) |
| 101 | +SIMPLE_SIL_TYPE_ATTR(error_indirect, ErrorIndirect) |
| 102 | +SIMPLE_SIL_TYPE_ATTR(error_unowned, ErrorUnowned) |
| 103 | +SIMPLE_SIL_TYPE_ATTR(out, Out) |
| 104 | +SIMPLE_SIL_TYPE_ATTR(direct, Direct) |
| 105 | +SIMPLE_SIL_TYPE_ATTR(in, In) |
| 106 | +SIMPLE_SIL_TYPE_ATTR(inout, Inout) |
| 107 | +SIMPLE_SIL_TYPE_ATTR(inout_aliasable, InoutAliasable) |
| 108 | +SIMPLE_SIL_TYPE_ATTR(in_guaranteed, InGuaranteed) |
| 109 | +SIMPLE_SIL_TYPE_ATTR(in_constant, InConstant) |
| 110 | +SIMPLE_SIL_TYPE_ATTR(pack_owned, PackOwned) |
| 111 | +SIMPLE_SIL_TYPE_ATTR(pack_guaranteed, PackGuaranteed) |
| 112 | +SIMPLE_SIL_TYPE_ATTR(pack_inout, PackInout) |
| 113 | +SIMPLE_SIL_TYPE_ATTR(pack_out, PackOut) |
| 114 | +SIMPLE_SIL_TYPE_ATTR(owned, Owned) |
| 115 | +SIMPLE_SIL_TYPE_ATTR(unowned_inner_pointer, UnownedInnerPointer) |
| 116 | +SIMPLE_SIL_TYPE_ATTR(guaranteed, Guaranteed) |
| 117 | +SIMPLE_SIL_TYPE_ATTR(autoreleased, Autoreleased) |
| 118 | +SIMPLE_SIL_TYPE_ATTR(callee_owned, CalleeOwned) |
| 119 | +SIMPLE_SIL_TYPE_ATTR(callee_guaranteed, CalleeGuaranteed) |
| 120 | +SIMPLE_SIL_TYPE_ATTR(objc_metatype, ObjCMetatype) |
| 121 | +SIL_TYPE_ATTR(opened, Opened) |
| 122 | +SIL_TYPE_ATTR(pack_element, PackElement) |
| 123 | +SIMPLE_SIL_TYPE_ATTR(pseudogeneric, Pseudogeneric) |
| 124 | +SIMPLE_SIL_TYPE_ATTR(unimplementable, Unimplementable) |
| 125 | +SIMPLE_SIL_TYPE_ATTR(yields, Yields) |
| 126 | +SIMPLE_SIL_TYPE_ATTR(yield_once, YieldOnce) |
| 127 | +SIMPLE_SIL_TYPE_ATTR(yield_many, YieldMany) |
| 128 | +SIMPLE_SIL_TYPE_ATTR(captures_generics, CapturesGenerics) |
100 | 129 | // Used at the SIL level to mark a type as moveOnly.
|
101 |
| -TYPE_ATTR(moveOnly) |
102 |
| -TYPE_ATTR(isolated) |
| 130 | +SIMPLE_SIL_TYPE_ATTR(moveOnly, MoveOnly) |
| 131 | +SIMPLE_SIL_TYPE_ATTR(isolated, Isolated) |
103 | 132 |
|
104 | 133 | // SIL metatype attributes.
|
105 |
| -TYPE_ATTR(thin) |
106 |
| -TYPE_ATTR(thick) |
| 134 | +SIMPLE_SIL_TYPE_ATTR(thin, Thin) |
| 135 | +SIMPLE_SIL_TYPE_ATTR(thick, Thick) |
107 | 136 |
|
108 | 137 | // Declaration Attributes and Modifers
|
109 | 138 | DECL_ATTR(_silgen_name, SILGenName,
|
@@ -548,6 +577,9 @@ SIMPLE_DECL_ATTR(_noObjCBridging, NoObjCBridging,
|
548 | 577 | OnAbstractFunction | OnSubscript | UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
|
549 | 578 | 155)
|
550 | 579 |
|
| 580 | +#undef SIMPLE_SIL_TYPE_ATTR |
| 581 | +#undef SIMPLE_TYPE_ATTR |
| 582 | +#undef SIL_TYPE_ATTR |
551 | 583 | #undef TYPE_ATTR
|
552 | 584 | #undef DECL_ATTR_ALIAS
|
553 | 585 | #undef CONTEXTUAL_DECL_ATTR_ALIAS
|
|
0 commit comments