mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Remove @unavailable, and move to introducing basic (sham) parsing for @availability.
The parsing here for @availability isn't real yet; but it provides scaffolding. Intended grammar: @availability(*, unavailable, message="...") @availability(*, unavailable) @availability(ios, unavailable) and so on. Much of this doesn't work yet in a general way, but I wanted something basic to work with to start with to wire up the functionality for @availability end-to-end (at least for 'unavailable'). As part of this, extend DECL_ATTR to include whether or not an attribute supports multiple declarations, and use this for @availability. Also hardwire darwin platforms, which we will need to have this list come from somewhere. The checking could be done at parsing or elsewhere. Swift SVN r15491
This commit is contained in:
@@ -101,12 +101,18 @@ void DeclAttribute::print(ASTPrinter &Printer) const {
|
||||
case DAK_asmname:
|
||||
Printer << "@asmname(\"" << cast<AsmnameAttr>(this)->Name << "\")";
|
||||
break;
|
||||
case DAK_unavailable: {
|
||||
Printer << "@unavailable";
|
||||
auto Attr = cast<UnavailableAttr>(this);
|
||||
case DAK_availability: {
|
||||
Printer << "@availability(";
|
||||
auto Attr = cast<AvailabilityAttr>(this);
|
||||
if (!Attr->hasPlatform())
|
||||
Printer << '*';
|
||||
else
|
||||
Printer << Attr->Platform;
|
||||
|
||||
if (!Attr->Message.empty()) {
|
||||
Printer << "(\"" << Attr->Message << "\")";
|
||||
Printer << ", message=\""<< Attr->Message << "\"";
|
||||
}
|
||||
Printer << ')';
|
||||
break;
|
||||
}
|
||||
case DAK_Count:
|
||||
@@ -120,10 +126,10 @@ void DeclAttribute::print(llvm::raw_ostream &OS) const {
|
||||
print(P);
|
||||
}
|
||||
|
||||
unsigned DeclAttribute::canAppear() const {
|
||||
switch (getKind()) {
|
||||
unsigned DeclAttribute::getOptions(DeclAttrKind DK) {
|
||||
switch (DK) {
|
||||
case DAK_Count:
|
||||
llvm_unreachable("canAppear needs a valid attribute");
|
||||
llvm_unreachable("getOptions needs a valid attribute");
|
||||
break;
|
||||
#define DECL_ATTR(NAME, OPTIONS)\
|
||||
case DAK_##NAME: return OPTIONS;
|
||||
|
||||
Reference in New Issue
Block a user