@@ -83,8 +83,8 @@ StringRef swift::getAccessLevelSpelling(AccessLevel value) {
8383
8484SourceLoc TypeAttribute::getStartLoc () const {
8585 switch (getKind ()) {
86- #define TYPE_ATTR (SPELLING , CLASS ) \
87- case TAK_ ## SPELLING: \
86+ #define TYPE_ATTR (_ , CLASS ) \
87+ case TAK_##CLASS: \
8888 return static_cast <const CLASS##TypeAttr *>(this )->getStartLocImpl ();
8989#include " swift/AST/Attr.def"
9090 }
@@ -93,8 +93,8 @@ SourceLoc TypeAttribute::getStartLoc() const {
9393
9494SourceLoc TypeAttribute::getEndLoc () const {
9595 switch (getKind ()) {
96- #define TYPE_ATTR (SPELLING , CLASS ) \
97- case TAK_ ## SPELLING: \
96+ #define TYPE_ATTR (_ , CLASS ) \
97+ case TAK_##CLASS: \
9898 return static_cast <const CLASS##TypeAttr *>(this )->getEndLocImpl ();
9999#include " swift/AST/Attr.def"
100100 }
@@ -103,10 +103,10 @@ SourceLoc TypeAttribute::getEndLoc() const {
103103
104104SourceRange TypeAttribute::getSourceRange () const {
105105 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 ()); \
110110 }
111111#include " swift/AST/Attr.def"
112112 }
@@ -119,15 +119,17 @@ SourceRange TypeAttribute::getSourceRange() const {
119119llvm::Optional<TypeAttrKind>
120120TypeAttribute::getAttrKindFromString (StringRef Str) {
121121 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 )
123123#include " swift/AST/Attr.def"
124- .Default (llvm::Optional<TypeAttrKind>() );
124+ .Default (llvm::None );
125125}
126126
127127// / Return the name (like "autoclosure") for an attribute ID.
128128const char *TypeAttribute::getAttrName (TypeAttrKind kind) {
129129 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;
131133#include " swift/AST/Attr.def"
132134 }
133135 llvm_unreachable (" unknown type attribute kind" );
@@ -142,11 +144,11 @@ TypeAttribute *TypeAttribute::createSimple(const ASTContext &context,
142144 // The simple cases should all be doing the exact same thing, and we
143145 // can reasonably hope that the optimizer will unify them so that this
144146 // 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: \
147149 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: \
150152 return new (context) CLASS##TypeAttr (atLoc, attrLoc);
151153#include " swift/AST/Attr.def"
152154 }
@@ -162,17 +164,16 @@ void TypeAttribute::dump() const {
162164void TypeAttribute::print (ASTPrinter &printer,
163165 const PrintOptions &options) const {
164166 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:
168169#include " swift/AST/Attr.def"
169170 printer.printSimpleAttr (getAttrName (getKind ()), /* needAt*/ true );
170171 return ;
171172
172- #define TYPE_ATTR (SPELLING , CLASS ) \
173- case TAK_ ## SPELLING: \
173+ #define TYPE_ATTR (_ , CLASS ) \
174+ case TAK_##CLASS: \
174175 return cast<CLASS##TypeAttr>(this )->printImpl (printer, options);
175- #define SIMPLE_TYPE_ATTR (SPELLING , C )
176+ #define SIMPLE_TYPE_ATTR (_ , C )
176177#include " swift/AST/Attr.def"
177178 }
178179 llvm_unreachable (" bad kind" );
0 commit comments