@@ -31,21 +31,22 @@ namespace swift {
31
31
class AbstractFunctionDecl ;
32
32
class LifetimeDependentReturnTypeRepr ;
33
33
34
- enum class LifetimeDependenceKind : uint8_t {
35
- Copy = 0 ,
36
- Consume,
37
- Borrow,
38
- Mutate
34
+ enum class ParsedLifetimeDependenceKind : uint8_t {
35
+ Default = 0 ,
36
+ Scope,
37
+ Inherit // Only used with deserialized decls
39
38
};
40
39
40
+ enum class LifetimeDependenceKind : uint8_t { Inherit = 0 , Scope };
41
+
41
42
class LifetimeDependenceSpecifier {
42
43
public:
43
44
enum class SpecifierKind { Named, Ordered, Self };
44
45
45
46
private:
46
47
SourceLoc loc;
47
48
SpecifierKind specifierKind;
48
- LifetimeDependenceKind lifetimeDependenceKind ;
49
+ ParsedLifetimeDependenceKind parsedLifetimeDependenceKind ;
49
50
union Value {
50
51
struct {
51
52
Identifier name;
@@ -60,35 +61,36 @@ class LifetimeDependenceSpecifier {
60
61
Value () {}
61
62
} value;
62
63
63
- LifetimeDependenceSpecifier (SourceLoc loc, SpecifierKind specifierKind,
64
- LifetimeDependenceKind lifetimeDependenceKind ,
65
- Value value)
64
+ LifetimeDependenceSpecifier (
65
+ SourceLoc loc, SpecifierKind specifierKind ,
66
+ ParsedLifetimeDependenceKind parsedLifetimeDependenceKind, Value value)
66
67
: loc(loc), specifierKind(specifierKind),
67
- lifetimeDependenceKind (lifetimeDependenceKind), value(value) {}
68
+ parsedLifetimeDependenceKind (parsedLifetimeDependenceKind),
69
+ value(value) {}
68
70
69
71
public:
70
72
static LifetimeDependenceSpecifier getNamedLifetimeDependenceSpecifier (
71
- SourceLoc loc, LifetimeDependenceKind kind, Identifier name) {
73
+ SourceLoc loc, ParsedLifetimeDependenceKind kind, Identifier name) {
72
74
return {loc, SpecifierKind::Named, kind, name};
73
75
}
74
76
75
77
static LifetimeDependenceSpecifier getOrderedLifetimeDependenceSpecifier (
76
- SourceLoc loc, LifetimeDependenceKind kind, unsigned index) {
78
+ SourceLoc loc, ParsedLifetimeDependenceKind kind, unsigned index) {
77
79
return {loc, SpecifierKind::Ordered, kind, index };
78
80
}
79
81
80
82
static LifetimeDependenceSpecifier
81
83
getSelfLifetimeDependenceSpecifier (SourceLoc loc,
82
- LifetimeDependenceKind kind) {
84
+ ParsedLifetimeDependenceKind kind) {
83
85
return {loc, SpecifierKind::Self, kind, {}};
84
86
}
85
87
86
88
SourceLoc getLoc () const { return loc; }
87
89
88
90
SpecifierKind getSpecifierKind () const { return specifierKind; }
89
91
90
- LifetimeDependenceKind getLifetimeDependenceKind () const {
91
- return lifetimeDependenceKind ;
92
+ ParsedLifetimeDependenceKind getParsedLifetimeDependenceKind () const {
93
+ return parsedLifetimeDependenceKind ;
92
94
}
93
95
94
96
Identifier getName () const {
@@ -113,19 +115,17 @@ class LifetimeDependenceSpecifier {
113
115
llvm_unreachable (" Invalid LifetimeDependenceSpecifier::SpecifierKind" );
114
116
}
115
117
116
- StringRef getLifetimeDependenceKindString () const {
117
- switch (lifetimeDependenceKind) {
118
- case LifetimeDependenceKind::Borrow:
119
- return " _borrow" ;
120
- case LifetimeDependenceKind::Consume:
121
- return " _consume" ;
122
- case LifetimeDependenceKind::Copy:
123
- return " _copy" ;
124
- case LifetimeDependenceKind::Mutate:
125
- return " _mutate" ;
118
+ std::string getLifetimeDependenceSpecifierString () const {
119
+ switch (parsedLifetimeDependenceKind) {
120
+ case ParsedLifetimeDependenceKind::Default:
121
+ return " @dependsOn(" + getParamString () + " )" ;
122
+ case ParsedLifetimeDependenceKind::Scope:
123
+ return " @dependsOn(scoped " + getParamString () + " )" ;
124
+ case ParsedLifetimeDependenceKind::Inherit:
125
+ return " @dependsOn(inherited " + getParamString () + " )" ;
126
126
}
127
127
llvm_unreachable (
128
- " Invalid LifetimeDependenceSpecifier::LifetimeDependenceKind " );
128
+ " Invalid LifetimeDependenceSpecifier::ParsedLifetimeDependenceKind " );
129
129
}
130
130
};
131
131
@@ -136,7 +136,7 @@ class LifetimeDependenceInfo {
136
136
137
137
static LifetimeDependenceInfo getForParamIndex (AbstractFunctionDecl *afd,
138
138
unsigned index,
139
- ValueOwnership ownership );
139
+ LifetimeDependenceKind kind );
140
140
141
141
static std::optional<LifetimeDependenceInfo>
142
142
fromTypeRepr (AbstractFunctionDecl *afd, Type resultType, bool allowIndex);
0 commit comments