Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 037afa9

Browse files
committed
[APINotes] Preserve attributes from inactive versions.
...by wrapping them in another (new) attribute, SwiftVersionedAttr, or by noting their deletion in a SwiftVersionedRemovalAttr. This doesn't support other kinds of changes that can be made via API notes, such as nullability or wholesale type changes, but it's a place to start, and possibly sufficient for our goals. Part of rdar://problem/28618121.
1 parent 3e887ec commit 037afa9

File tree

4 files changed

+211
-90
lines changed

4 files changed

+211
-90
lines changed

include/clang/Basic/Attr.td

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ class VariadicEnumArgument<string name, string type, list<string> values,
192192
list<string> Enums = enums;
193193
}
194194

195+
// Represents an attribute wrapped by another attribute.
196+
class AttrArgument<string name, bit opt = 0> : Argument<name, opt>;
197+
195198
// This handles one spelling of an attribute.
196199
class Spelling<string name, string variety> {
197200
string Name = name;
@@ -1491,6 +1494,29 @@ def SwiftImportPropertyAsAccessors : InheritableAttr {
14911494
let Documentation = [Undocumented];
14921495
}
14931496

1497+
def SwiftVersioned : Attr {
1498+
// This attribute has no spellings as it is only ever created implicitly
1499+
// from API notes.
1500+
let Spellings = [];
1501+
let Args = [VersionArgument<"Version">, AttrArgument<"AttrToAdd">];
1502+
let SemaHandler = 0;
1503+
let Documentation = [Undocumented];
1504+
}
1505+
1506+
def SwiftVersionedRemoval : Attr {
1507+
// This attribute has no spellings as it is only ever created implicitly
1508+
// from API notes.
1509+
let Spellings = [];
1510+
let Args = [VersionArgument<"Version">, UnsignedArgument<"RawKind">];
1511+
let SemaHandler = 0;
1512+
let Documentation = [Undocumented];
1513+
let AdditionalMembers = [{
1514+
attr::Kind getAttrKindToRemove() const {
1515+
return static_cast<attr::Kind>(getRawKind());
1516+
}
1517+
}];
1518+
}
1519+
14941520
def ReqdWorkGroupSize : InheritableAttr {
14951521
let Spellings = [GNU<"reqd_work_group_size">];
14961522
let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,

0 commit comments

Comments
 (0)