Skip to content

Commit 3ce2e04

Browse files
committed
Sema: Remove IsRethrows field from AbstractFunction
1 parent 5470573 commit 3ce2e04

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,55 +205,63 @@ class AbstractFunction {
205205
Expr *TheExpr;
206206
};
207207
unsigned TheKind : 2;
208-
unsigned IsRethrows : 1;
209208
unsigned ParamCount : 2;
210-
FunctionRethrowingKind rethrowingKind;
209+
FunctionRethrowingKind RethrowingKind;
211210
ConcreteDeclRef declRef;
212211

213212
public:
214213
explicit AbstractFunction(Kind kind, Expr *fn, ConcreteDeclRef declRef)
215214
: TheKind(kind),
216-
IsRethrows(false),
217215
ParamCount(1),
218-
rethrowingKind(FunctionRethrowingKind::Invalid),
216+
RethrowingKind(FunctionRethrowingKind::None),
219217
declRef(declRef) {
220218
TheExpr = fn;
221219
}
222220

223221
explicit AbstractFunction(AbstractFunctionDecl *fn, ConcreteDeclRef declRef)
224222
: TheKind(Kind::Function),
225-
IsRethrows(fn->getAttrs().hasAttribute<RethrowsAttr>()),
226223
ParamCount(fn->getNumCurryLevels()),
227-
rethrowingKind(fn->getRethrowingKind()),
224+
RethrowingKind(fn->getRethrowingKind()),
228225
declRef(declRef) {
229226
TheFunction = fn;
230227
}
231228

232229
explicit AbstractFunction(AbstractClosureExpr *closure,
233230
ConcreteDeclRef declRef)
234231
: TheKind(Kind::Closure),
235-
IsRethrows(false),
236232
ParamCount(1),
237-
rethrowingKind(FunctionRethrowingKind::Invalid),
233+
RethrowingKind(FunctionRethrowingKind::None),
238234
declRef(declRef) {
239235
TheClosure = closure;
240236
}
241237

242238
explicit AbstractFunction(ParamDecl *parameter, ConcreteDeclRef declRef)
243239
: TheKind(Kind::Parameter),
244-
IsRethrows(false),
245240
ParamCount(1),
246-
rethrowingKind(FunctionRethrowingKind::Invalid),
241+
RethrowingKind(FunctionRethrowingKind::None),
247242
declRef(declRef) {
248243
TheParameter = parameter;
249244
}
250245

251246
Kind getKind() const { return Kind(TheKind); }
252247

253248
/// Whether the function is marked 'rethrows'.
254-
bool isBodyRethrows() const { return IsRethrows; }
249+
bool isBodyRethrows() const {
250+
switch (RethrowingKind) {
251+
case FunctionRethrowingKind::None:
252+
case FunctionRethrowingKind::Throws:
253+
return false;
254+
255+
case FunctionRethrowingKind::ByClosure:
256+
case FunctionRethrowingKind::ByConformance:
257+
case FunctionRethrowingKind::Invalid:
258+
return true;
259+
}
260+
}
255261

256-
FunctionRethrowingKind getRethrowingKind() const { return rethrowingKind; }
262+
FunctionRethrowingKind getRethrowingKind() const {
263+
return RethrowingKind;
264+
}
257265

258266
unsigned getNumArgumentsForFullApply() const {
259267
return ParamCount;

0 commit comments

Comments
 (0)