@@ -83,8 +83,8 @@ StringRef swift::getAccessLevelSpelling(AccessLevel value) {
83
83
84
84
SourceLoc TypeAttribute::getStartLoc () const {
85
85
switch (getKind ()) {
86
- #define TYPE_ATTR (SPELLING , CLASS ) \
87
- case TAK_ ## SPELLING: \
86
+ #define TYPE_ATTR (_ , CLASS ) \
87
+ case TAK_##CLASS: \
88
88
return static_cast <const CLASS##TypeAttr *>(this )->getStartLocImpl ();
89
89
#include " swift/AST/Attr.def"
90
90
}
@@ -93,8 +93,8 @@ SourceLoc TypeAttribute::getStartLoc() const {
93
93
94
94
SourceLoc TypeAttribute::getEndLoc () const {
95
95
switch (getKind ()) {
96
- #define TYPE_ATTR (SPELLING , CLASS ) \
97
- case TAK_ ## SPELLING: \
96
+ #define TYPE_ATTR (_ , CLASS ) \
97
+ case TAK_##CLASS: \
98
98
return static_cast <const CLASS##TypeAttr *>(this )->getEndLocImpl ();
99
99
#include " swift/AST/Attr.def"
100
100
}
@@ -103,10 +103,10 @@ SourceLoc TypeAttribute::getEndLoc() const {
103
103
104
104
SourceRange TypeAttribute::getSourceRange () const {
105
105
switch (getKind ()) {
106
- #define TYPE_ATTR (SPELLING , CLASS ) \
107
- case TAK_ ## SPELLING : { \
108
- auto attr = static_cast <const CLASS##TypeAttr *>(this ); \
109
- return SourceRange (attr->getStartLocImpl (), attr->getEndLocImpl ()); \
106
+ #define TYPE_ATTR (_ , CLASS ) \
107
+ case TAK_##CLASS : { \
108
+ auto attr = static_cast <const CLASS##TypeAttr *>(this ); \
109
+ return SourceRange (attr->getStartLocImpl (), attr->getEndLocImpl ()); \
110
110
}
111
111
#include " swift/AST/Attr.def"
112
112
}
@@ -119,15 +119,17 @@ SourceRange TypeAttribute::getSourceRange() const {
119
119
llvm::Optional<TypeAttrKind>
120
120
TypeAttribute::getAttrKindFromString (StringRef Str) {
121
121
return llvm::StringSwitch<llvm::Optional<TypeAttrKind>>(Str)
122
- #define TYPE_ATTR (X, C ) .Case(#X, TAK_##X )
122
+ #define TYPE_ATTR (X, C ) .Case(#X, TAK_##C )
123
123
#include " swift/AST/Attr.def"
124
- .Default (llvm::Optional<TypeAttrKind>() );
124
+ .Default (llvm::None );
125
125
}
126
126
127
127
// / Return the name (like "autoclosure") for an attribute ID.
128
128
const char *TypeAttribute::getAttrName (TypeAttrKind kind) {
129
129
switch (kind) {
130
- #define TYPE_ATTR (X, C ) case TAK_##X: return #X;
130
+ #define TYPE_ATTR (X, C ) \
131
+ case TAK_##C: \
132
+ return #X;
131
133
#include " swift/AST/Attr.def"
132
134
}
133
135
llvm_unreachable (" unknown type attribute kind" );
@@ -142,11 +144,11 @@ TypeAttribute *TypeAttribute::createSimple(const ASTContext &context,
142
144
// The simple cases should all be doing the exact same thing, and we
143
145
// can reasonably hope that the optimizer will unify them so that this
144
146
// function doesn't actually need a switch.
145
- #define TYPE_ATTR (SPELLING, CLASS ) \
146
- case TAK_##SPELLING: \
147
+ #define TYPE_ATTR (SPELLING, CLASS ) \
148
+ case TAK_##CLASS: \
147
149
llvm_unreachable (" not a simple attribute" );
148
- #define SIMPLE_TYPE_ATTR (SPELLING, CLASS ) \
149
- case TAK_##SPELLING: \
150
+ #define SIMPLE_TYPE_ATTR (SPELLING, CLASS ) \
151
+ case TAK_##CLASS: \
150
152
return new (context) CLASS##TypeAttr (atLoc, attrLoc);
151
153
#include " swift/AST/Attr.def"
152
154
}
@@ -162,17 +164,16 @@ void TypeAttribute::dump() const {
162
164
void TypeAttribute::print (ASTPrinter &printer,
163
165
const PrintOptions &options) const {
164
166
switch (getKind ()) {
165
- #define TYPE_ATTR (SPELLING, CLASS )
166
- #define SIMPLE_TYPE_ATTR (SPELLING, CLASS ) \
167
- case TAK_ ## SPELLING:
167
+ #define TYPE_ATTR (_, CLASS )
168
+ #define SIMPLE_TYPE_ATTR (_, CLASS ) case TAK_##CLASS:
168
169
#include " swift/AST/Attr.def"
169
170
printer.printSimpleAttr (getAttrName (getKind ()), /* needAt*/ true );
170
171
return ;
171
172
172
- #define TYPE_ATTR (SPELLING , CLASS ) \
173
- case TAK_ ## SPELLING: \
173
+ #define TYPE_ATTR (_ , CLASS ) \
174
+ case TAK_##CLASS: \
174
175
return cast<CLASS##TypeAttr>(this )->printImpl (printer, options);
175
- #define SIMPLE_TYPE_ATTR (SPELLING , C )
176
+ #define SIMPLE_TYPE_ATTR (_ , C )
176
177
#include " swift/AST/Attr.def"
177
178
}
178
179
llvm_unreachable (" bad kind" );
0 commit comments