Skip to content

Commit d222470

Browse files
committed
AST: Remove unused methods from CaptureInfo
1 parent a991179 commit d222470

File tree

7 files changed

+7
-51
lines changed

7 files changed

+7
-51
lines changed

include/swift/AST/AnyFunctionRef.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ class AnyFunctionRef {
8383
TheFunction.get<AbstractClosureExpr *>()->setCaptureInfo(captures);
8484
}
8585

86-
void getLocalCaptures(SmallVectorImpl<CapturedValue> &Result) const {
87-
getCaptureInfo().getLocalCaptures(Result);
88-
}
89-
9086
bool hasType() const {
9187
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
9288
return AFD->hasInterfaceType();

include/swift/AST/CaptureInfo.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,6 @@ class CaptureInfo {
197197
return StorageAndFlags.getPointer()->getCaptures();
198198
}
199199

200-
/// Return a filtered list of the captures for this function,
201-
/// filtering out global variables. This function returns the list that
202-
/// actually needs to be closed over.
203-
///
204-
void getLocalCaptures(SmallVectorImpl<CapturedValue> &Result) const;
205-
206-
/// \returns true if getLocalCaptures() will return a non-empty list.
207-
bool hasLocalCaptures() const;
208-
209200
/// \returns true if the function captures any generic type parameters.
210201
bool hasGenericParamCaptures() const {
211202
// FIXME: Ideally, everywhere that synthesizes a function should include

include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8019,10 +8019,6 @@ class FuncDecl : public AbstractFunctionDecl {
80198019
/// prior to type checking.
80208020
bool isBinaryOperator() const;
80218021

8022-
void getLocalCaptures(SmallVectorImpl<CapturedValue> &Result) const {
8023-
return getCaptureInfo().getLocalCaptures(Result);
8024-
}
8025-
80268022
ParamDecl **getImplicitSelfDeclStorage();
80278023

80288024
/// Get the supertype method this method overrides, if any.

lib/AST/CaptureInfo.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,7 @@ CaptureInfo CaptureInfo::empty() {
5959
return result;
6060
}
6161

62-
bool CaptureInfo::hasLocalCaptures() const {
63-
for (auto capture : getCaptures()) {
64-
if (capture.isLocalCapture())
65-
return true;
66-
}
67-
return false;
68-
}
69-
70-
71-
void CaptureInfo::
72-
getLocalCaptures(SmallVectorImpl<CapturedValue> &Result) const {
73-
if (!hasLocalCaptures()) return;
74-
75-
Result.reserve(getCaptures().size());
76-
77-
// Filter out global variables.
78-
for (auto capture : getCaptures()) {
79-
if (!capture.isLocalCapture())
80-
continue;
81-
82-
Result.push_back(capture);
83-
}
84-
}
85-
8662
VarDecl *CaptureInfo::getIsolatedParamCapture() const {
87-
if (!hasLocalCaptures())
88-
return nullptr;
89-
9063
for (const auto &capture : getCaptures()) {
9164
// NOTE: isLocalCapture() returns false if we have dynamic self metadata
9265
// since dynamic self metadata is never an isolated capture. So we can just

lib/SIL/IR/TypeLowering.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4153,9 +4153,10 @@ TypeConverter::getLoweredLocalCaptures(SILDeclRef fn) {
41534153
if (captureInfo.hasOpaqueValueCapture())
41544154
capturesOpaqueValue = captureInfo.getOpaqueValue();
41554155

4156-
SmallVector<CapturedValue, 4> localCaptures;
4157-
captureInfo.getLocalCaptures(localCaptures);
4158-
for (auto capture : localCaptures) {
4156+
for (auto capture : captureInfo.getCaptures()) {
4157+
if (!capture.isLocalCapture())
4158+
continue;
4159+
41594160
// If the capture is of another local function, grab its transitive
41604161
// captures instead.
41614162
if (auto capturedFn = getAnyFunctionRefFromCapture(capture)) {

lib/SILOptimizer/Differentiation/Common.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ findMinimalDerivativeConfiguration(AbstractFunctionDecl *original,
475475
original->getInterfaceType()->castTo<AnyFunctionType>());
476476

477477
if (silParameterIndices->getCapacity() < parameterIndices->getCapacity()) {
478-
assert(original->getCaptureInfo().hasLocalCaptures());
479478
silParameterIndices =
480479
silParameterIndices->extendingCapacity(original->getASTContext(),
481480
parameterIndices->getCapacity());

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,9 +2478,9 @@ namespace {
24782478

24792479
/// Check closure captures for Sendable violations.
24802480
void checkLocalCaptures(AnyFunctionRef localFunc) {
2481-
SmallVector<CapturedValue, 2> captures;
2482-
localFunc.getCaptureInfo().getLocalCaptures(captures);
2483-
for (const auto &capture : captures) {
2481+
for (const auto &capture : localFunc.getCaptureInfo().getCaptures()) {
2482+
if (!capture.isLocalCapture())
2483+
continue;
24842484
if (capture.isDynamicSelfMetadata())
24852485
continue;
24862486
if (capture.isOpaqueValue())

0 commit comments

Comments
 (0)