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

Commit f8c16c2

Browse files
authored
[APINotes] Preserve attributes from inactive versions. (#53)
...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 0141a6c commit f8c16c2

File tree

6 files changed

+231
-92
lines changed

6 files changed

+231
-92
lines changed

include/clang/AST/Attr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "clang/Basic/Sanitizers.h"
2525
#include "clang/Basic/SourceLocation.h"
2626
#include "clang/Basic/VersionTuple.h"
27+
#include "llvm/ADT/PointerEmbeddedInt.h"
2728
#include "llvm/ADT/StringSwitch.h"
2829
#include "llvm/Support/ErrorHandling.h"
2930
#include "llvm/Support/raw_ostream.h"

include/clang/Basic/Attr.td

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

198+
// Represents an attribute wrapped by another attribute.
199+
class AttrArgument<string name, bit opt = 0> : Argument<name, opt>;
200+
198201
// This handles one spelling of an attribute.
199202
class Spelling<string name, string variety> {
200203
string Name = name;
@@ -1500,6 +1503,29 @@ def SwiftImportPropertyAsAccessors : InheritableAttr {
15001503
let Documentation = [Undocumented];
15011504
}
15021505

1506+
def SwiftVersioned : 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">, AttrArgument<"AttrToAdd">];
1511+
let SemaHandler = 0;
1512+
let Documentation = [Undocumented];
1513+
}
1514+
1515+
def SwiftVersionedRemoval : Attr {
1516+
// This attribute has no spellings as it is only ever created implicitly
1517+
// from API notes.
1518+
let Spellings = [];
1519+
let Args = [VersionArgument<"Version">, UnsignedArgument<"RawKind">];
1520+
let SemaHandler = 0;
1521+
let Documentation = [Undocumented];
1522+
let AdditionalMembers = [{
1523+
attr::Kind getAttrKindToRemove() const {
1524+
return static_cast<attr::Kind>(getRawKind());
1525+
}
1526+
}];
1527+
}
1528+
15031529
def ReqdWorkGroupSize : InheritableAttr {
15041530
let Spellings = [GNU<"reqd_work_group_size">];
15051531
let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">,

0 commit comments

Comments
 (0)