[Statement checker] Remove redundant state.

Remove the `TheFunc` state, which is used only in a few places and can
be trivially recomputed.
This commit is contained in:
Doug Gregor
2020-08-02 00:06:39 -07:00
parent 5dc9b1ed00
commit cc17aef8c5
2 changed files with 31 additions and 23 deletions

View File

@@ -53,6 +53,20 @@ public:
}
}
/// Construct an AnyFunctionRef from a decl context that might be
/// some sort of function.
static Optional<AnyFunctionRef> fromDeclContext(DeclContext *dc) {
if (auto fn = dyn_cast<AbstractFunctionDecl>(dc)) {
return AnyFunctionRef(fn);
}
if (auto ace = dyn_cast<AbstractClosureExpr>(dc)) {
return AnyFunctionRef(ace);
}
return None;
}
CaptureInfo getCaptureInfo() const {
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
return AFD->getCaptureInfo();