Skip to content

Commit c00072d

Browse files
committed
[NFC] Rename/reorg LifetimeDependence utils
1 parent dae5cc3 commit c00072d

File tree

2 files changed

+161
-156
lines changed

2 files changed

+161
-156
lines changed

include/swift/AST/LifetimeDependence.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ enum class ParsedLifetimeDependenceKind : uint8_t {
4343

4444
enum class LifetimeDependenceKind : uint8_t { Inherit = 0, Scope };
4545

46-
class LifetimeDependenceSpecifier {
47-
public:
48-
enum class SpecifierKind { Named, Ordered, Self, Immortal };
46+
enum class LifetimeSpecifierKind { Named, Ordered, Self, Immortal };
4947

48+
class LifetimeDependenceSpecifier {
5049
private:
5150
SourceLoc loc;
52-
SpecifierKind specifierKind;
51+
LifetimeSpecifierKind specifierKind;
5352
ParsedLifetimeDependenceKind parsedLifetimeDependenceKind;
5453
union Value {
5554
struct {
@@ -66,7 +65,7 @@ class LifetimeDependenceSpecifier {
6665
} value;
6766

6867
LifetimeDependenceSpecifier(
69-
SourceLoc loc, SpecifierKind specifierKind,
68+
SourceLoc loc, LifetimeSpecifierKind specifierKind,
7069
ParsedLifetimeDependenceKind parsedLifetimeDependenceKind, Value value)
7170
: loc(loc), specifierKind(specifierKind),
7271
parsedLifetimeDependenceKind(parsedLifetimeDependenceKind),
@@ -82,7 +81,7 @@ class LifetimeDependenceSpecifier {
8281

8382
static LifetimeDependenceSpecifier
8483
getImmortalLifetimeDependenceSpecifier(SourceLoc loc) {
85-
return {loc, SpecifierKind::Immortal, {}, {}};
84+
return {loc, LifetimeSpecifierKind::Immortal, {}, {}};
8685
}
8786

8887
static LifetimeDependenceSpecifier getOrderedLifetimeDependenceSpecifier(
@@ -100,34 +99,34 @@ class LifetimeDependenceSpecifier {
10099

101100
SourceLoc getLoc() const { return loc; }
102101

103-
SpecifierKind getSpecifierKind() const { return specifierKind; }
102+
LifetimeSpecifierKind getSpecifierKind() const { return specifierKind; }
104103

105104
ParsedLifetimeDependenceKind getParsedLifetimeDependenceKind() const {
106105
return parsedLifetimeDependenceKind;
107106
}
108107

109108
Identifier getName() const {
110-
assert(specifierKind == SpecifierKind::Named);
109+
assert(specifierKind == LifetimeSpecifierKind::Named);
111110
return value.Named.name;
112111
}
113112

114113
unsigned getIndex() const {
115-
assert(specifierKind == SpecifierKind::Ordered);
114+
assert(specifierKind == LifetimeSpecifierKind::Ordered);
116115
return value.Ordered.index;
117116
}
118117

119118
std::string getParamString() const {
120119
switch (specifierKind) {
121-
case SpecifierKind::Named:
120+
case LifetimeSpecifierKind::Named:
122121
return value.Named.name.str().str();
123-
case SpecifierKind::Self:
122+
case LifetimeSpecifierKind::Self:
124123
return "self";
125-
case SpecifierKind::Ordered:
124+
case LifetimeSpecifierKind::Ordered:
126125
return std::to_string(value.Ordered.index);
127-
case SpecifierKind::Immortal:
126+
case LifetimeSpecifierKind::Immortal:
128127
return "immortal";
129128
}
130-
llvm_unreachable("Invalid LifetimeDependenceSpecifier::SpecifierKind");
129+
llvm_unreachable("Invalid LifetimeSpecifierKind");
131130
}
132131

133132
std::string getLifetimeDependenceSpecifierString() const {
@@ -155,10 +154,10 @@ class LifetimeDependenceInfo {
155154
unsigned sourceIndex,
156155
LifetimeDependenceKind kind);
157156

158-
/// Builds LifetimeDependenceInfo on a result or parameter from a swift decl
157+
/// Builds LifetimeDependenceInfo from dependsOn type modifier
159158
static std::optional<LifetimeDependenceInfo>
160-
fromTypeRepr(AbstractFunctionDecl *afd, LifetimeDependentTypeRepr *typeRepr,
161-
unsigned targetIndex);
159+
fromDependsOn(AbstractFunctionDecl *afd, TypeRepr *targetRepr,
160+
Type targetType, unsigned targetIndex);
162161

163162
/// Infer LifetimeDependenceInfo on result
164163
static std::optional<LifetimeDependenceInfo> infer(AbstractFunctionDecl *afd);
@@ -173,9 +172,9 @@ class LifetimeDependenceInfo {
173172

174173
/// Builds LifetimeDependenceInfo from SIL function type
175174
static std::optional<LifetimeDependenceInfo>
176-
fromTypeRepr(LifetimeDependentTypeRepr *lifetimeDependentRepr,
177-
unsigned targetIndex, ArrayRef<SILParameterInfo> params,
178-
DeclContext *dc);
175+
fromDependsOn(LifetimeDependentTypeRepr *lifetimeDependentRepr,
176+
unsigned targetIndex, ArrayRef<SILParameterInfo> params,
177+
DeclContext *dc);
179178

180179
public:
181180
LifetimeDependenceInfo(IndexSubset *inheritLifetimeParamIndices,

0 commit comments

Comments
 (0)