Skip to content

Commit 87593fc

Browse files
committed
ASTScope: Fold AbstractFunctionBodyScope into FunctionBodyScope
1 parent d37318b commit 87593fc

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

include/swift/AST/ASTScope.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,13 @@ class ParameterListScope final : public ASTScopeImpl {
929929
NullablePtr<const void> addressForPrinting() const override { return params; }
930930
};
931931

932-
class AbstractFunctionBodyScope : public ASTScopeImpl {
932+
/// Body of functions, methods, constructors, destructors and accessors.
933+
class FunctionBodyScope : public ASTScopeImpl {
933934
public:
934935
AbstractFunctionDecl *const decl;
935936

936-
AbstractFunctionBodyScope(AbstractFunctionDecl *e) : decl(e) {}
937-
virtual ~AbstractFunctionBodyScope() {}
937+
FunctionBodyScope(AbstractFunctionDecl *e) : decl(e) {}
938+
virtual ~FunctionBodyScope() {}
938939

939940
protected:
940941
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
@@ -956,19 +957,11 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
956957
bool lookupLocalsOrMembers(DeclConsumer) const override;
957958

958959
public:
960+
std::string getClassName() const override;
959961
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion() override;
960962
SourceRange sourceRangeForDeferredExpansion() const override;
961963
};
962964

963-
/// Body of functions and methods.
964-
class FunctionBodyScope final : public AbstractFunctionBodyScope {
965-
public:
966-
FunctionBodyScope(AbstractFunctionDecl *e)
967-
: AbstractFunctionBodyScope(e) {}
968-
std::string getClassName() const override;
969-
bool lookupLocalsOrMembers(DeclConsumer consumer) const override;
970-
};
971-
972965
class DefaultArgumentInitializerScope final : public ASTScopeImpl {
973966
public:
974967
ParamDecl *const decl;

lib/AST/ASTScopeCreation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ CREATES_NEW_INSERTION_POINT(GenericTypeOrExtensionScope)
984984
CREATES_NEW_INSERTION_POINT(BraceStmtScope)
985985
CREATES_NEW_INSERTION_POINT(TopLevelCodeScope)
986986

987-
NO_NEW_INSERTION_POINT(AbstractFunctionBodyScope)
987+
NO_NEW_INSERTION_POINT(FunctionBodyScope)
988988
NO_NEW_INSERTION_POINT(AbstractFunctionDeclScope)
989989
NO_NEW_INSERTION_POINT(AttachedPropertyWrapperScope)
990990
NO_NEW_INSERTION_POINT(EnumElementScope)
@@ -1224,7 +1224,7 @@ void EnumElementScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
12241224
// scopeCreator.addToScopeTree(decl->getStructuralRawValueExpr(), this);
12251225
}
12261226

1227-
void AbstractFunctionBodyScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
1227+
void FunctionBodyScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
12281228
ScopeCreator &scopeCreator) {
12291229
expandBody(scopeCreator);
12301230
}
@@ -1552,7 +1552,7 @@ void *ScopeCreator::operator new(size_t bytes, const ASTContext &ctx,
15521552

15531553
#pragma mark - expandBody
15541554

1555-
void AbstractFunctionBodyScope::expandBody(ScopeCreator &scopeCreator) {
1555+
void FunctionBodyScope::expandBody(ScopeCreator &scopeCreator) {
15561556
scopeCreator.addToScopeTree(decl->getBody(), this);
15571557
}
15581558

@@ -1615,7 +1615,7 @@ NullablePtr<ASTScopeImpl> ASTScopeImpl::insertionPointForDeferredExpansion() {
16151615
}
16161616

16171617
NullablePtr<ASTScopeImpl>
1618-
AbstractFunctionBodyScope::insertionPointForDeferredExpansion() {
1618+
FunctionBodyScope::insertionPointForDeferredExpansion() {
16191619
return getParent().get();
16201620
}
16211621

lib/AST/ASTScopeLookup.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,13 @@ bool CaseStmtBodyScope::lookupLocalsOrMembers(DeclConsumer consumer) const {
302302
return false;
303303
}
304304

305-
bool AbstractFunctionBodyScope::lookupLocalsOrMembers(
305+
bool FunctionBodyScope::lookupLocalsOrMembers(
306306
DeclConsumer consumer) const {
307307
if (auto *paramList = decl->getParameters()) {
308308
for (auto *paramDecl : *paramList)
309309
if (consumer.consume({paramDecl}, DeclVisibilityKind::FunctionParameter))
310310
return true;
311311
}
312-
return false;
313-
}
314-
315-
bool FunctionBodyScope::lookupLocalsOrMembers(DeclConsumer consumer) const {
316-
if (AbstractFunctionBodyScope::lookupLocalsOrMembers(consumer))
317-
return true;
318312

319313
if (decl->getDeclContext()->isTypeContext()) {
320314
return consumer.consume({decl->getImplicitSelfDecl()},

lib/AST/ASTScopeSourceRange.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ SourceRange DifferentiableAttributeScope::getSourceRangeOfThisASTNode(
213213
return differentiableAttr->getRange();
214214
}
215215

216-
SourceRange AbstractFunctionBodyScope::getSourceRangeOfThisASTNode(
216+
SourceRange FunctionBodyScope::getSourceRangeOfThisASTNode(
217217
const bool omitAssertions) const {
218218
return decl->getOriginalBodySourceRange();
219219
}
@@ -592,7 +592,7 @@ SourceRange ASTScopeImpl::sourceRangeForDeferredExpansion() const {
592592
SourceRange IterableTypeScope::sourceRangeForDeferredExpansion() const {
593593
return portion->sourceRangeForDeferredExpansion(this);
594594
}
595-
SourceRange AbstractFunctionBodyScope::sourceRangeForDeferredExpansion() const {
595+
SourceRange FunctionBodyScope::sourceRangeForDeferredExpansion() const {
596596
const auto bsr = decl->getOriginalBodySourceRange();
597597
const SourceLoc endEvenIfNoCloseBraceAndEndsWithInterpolatedStringLiteral =
598598
getLocEncompassingPotentialLookups(getSourceManager(), bsr.End);

0 commit comments

Comments
 (0)