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