Skip to content

Commit 3295725

Browse files
committed
ASTScope: Remove VarDeclScope
1 parent de08e25 commit 3295725

File tree

5 files changed

+5
-66
lines changed

5 files changed

+5
-66
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,6 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
10611061

10621062
protected:
10631063
void printSpecifics(llvm::raw_ostream &out) const override;
1064-
void forEachVarDeclWithLocalizableAccessors(
1065-
ScopeCreator &scopeCreator, function_ref<void(VarDecl *)> foundOne) const;
10661064

10671065
public:
10681066
NullablePtr<Decl> getDeclIfAny() const override { return decl; }
@@ -1370,37 +1368,6 @@ class SubscriptDeclScope final : public ASTScopeImpl {
13701368
}
13711369
};
13721370

1373-
class VarDeclScope final : public ASTScopeImpl {
1374-
1375-
public:
1376-
VarDecl *const decl;
1377-
VarDeclScope(VarDecl *e) : decl(e) {}
1378-
virtual ~VarDeclScope() {}
1379-
1380-
protected:
1381-
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
1382-
1383-
private:
1384-
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
1385-
1386-
public:
1387-
std::string getClassName() const override;
1388-
SourceRange
1389-
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1390-
1391-
protected:
1392-
void printSpecifics(llvm::raw_ostream &out) const override;
1393-
1394-
public:
1395-
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
1396-
Decl *getDecl() const { return decl; }
1397-
NullablePtr<const void> getReferrent() const override;
1398-
NullablePtr<AbstractStorageDecl>
1399-
getEnclosingAbstractStorageDecl() const override {
1400-
return decl;
1401-
}
1402-
};
1403-
14041371
class EnumElementScope : public ASTScopeImpl {
14051372
EnumElementDecl *const decl;
14061373

lib/AST/ASTScope.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ DEFINE_GET_CLASS_NAME(TopLevelCodeScope)
198198
DEFINE_GET_CLASS_NAME(SpecializeAttributeScope)
199199
DEFINE_GET_CLASS_NAME(DifferentiableAttributeScope)
200200
DEFINE_GET_CLASS_NAME(SubscriptDeclScope)
201-
DEFINE_GET_CLASS_NAME(VarDeclScope)
202201
DEFINE_GET_CLASS_NAME(EnumElementScope)
203202
DEFINE_GET_CLASS_NAME(IfStmtScope)
204203
DEFINE_GET_CLASS_NAME(WhileStmtScope)

lib/AST/ASTScopeCreation.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,6 @@ NO_NEW_INSERTION_POINT(IfStmtScope)
973973
NO_NEW_INSERTION_POINT(RepeatWhileScope)
974974
NO_NEW_INSERTION_POINT(SubscriptDeclScope)
975975
NO_NEW_INSERTION_POINT(SwitchStmtScope)
976-
NO_NEW_INSERTION_POINT(VarDeclScope)
977976
NO_NEW_INSERTION_POINT(WhileStmtScope)
978977

979978
NO_EXPANSION(GenericParamScope)
@@ -1019,6 +1018,7 @@ PatternEntryDeclScope::expandAScopeThatCreatesANewInsertionPoint(
10191018
ScopeCreator &scopeCreator) {
10201019
// Initializers come before VarDecls, e.g. PCMacro/didSet.swift 19
10211020
auto patternEntry = getPatternEntry();
1021+
10221022
// Create a child for the initializer, if present.
10231023
// Cannot trust the source range given in the ASTScopeImpl for the end of the
10241024
// initializer (because of InterpolatedLiteralStrings and EditorPlaceHolders),
@@ -1035,10 +1035,12 @@ PatternEntryDeclScope::expandAScopeThatCreatesANewInsertionPoint(
10351035
.constructExpandAndInsertUncheckable<PatternEntryInitializerScope>(
10361036
this, decl, patternEntryIndex, vis);
10371037
}
1038+
10381039
// Add accessors for the variables in this pattern.
1039-
forEachVarDeclWithLocalizableAccessors(scopeCreator, [&](VarDecl *var) {
1040-
scopeCreator.ifUniqueConstructExpandAndInsert<VarDeclScope>(this, var);
1040+
patternEntry.getPattern()->forEachVariable([&](VarDecl *var) {
1041+
scopeCreator.addChildrenForAllLocalizableAccessorsInSourceOrder(var, this);
10411042
});
1043+
10421044
ASTScopeAssert(!handleUseBeforeDef,
10431045
"next line is wrong otherwise; would need a use scope");
10441046

@@ -1273,11 +1275,6 @@ void CaseStmtBodyScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
12731275
scopeCreator.addToScopeTree(stmt->getBody(), this);
12741276
}
12751277

1276-
void VarDeclScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
1277-
ScopeCreator &scopeCreator) {
1278-
scopeCreator.addChildrenForAllLocalizableAccessorsInSourceOrder(decl, this);
1279-
}
1280-
12811278
void SubscriptDeclScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
12821279
ScopeCreator &scopeCreator) {
12831280
scopeCreator.addChildrenForKnownAttributes(decl, this);
@@ -1427,19 +1424,6 @@ AbstractPatternEntryScope::AbstractPatternEntryScope(
14271424
"out of bounds");
14281425
}
14291426

1430-
void AbstractPatternEntryScope::forEachVarDeclWithLocalizableAccessors(
1431-
ScopeCreator &scopeCreator, function_ref<void(VarDecl *)> foundOne) const {
1432-
getPatternEntry().getPattern()->forEachVariable([&](VarDecl *var) {
1433-
bool hasParsedAccessors = false;
1434-
var->visitParsedAccessors([&](AccessorDecl *) {
1435-
hasParsedAccessors = true;
1436-
});
1437-
1438-
if (hasParsedAccessors)
1439-
foundOne(var);
1440-
});
1441-
}
1442-
14431427
// Following must be after uses to ensure templates get instantiated
14441428
#pragma mark getEnclosingAbstractStorageDecl
14451429

@@ -1531,7 +1515,6 @@ GET_REFERRENT(AbstractFunctionDeclScope, getDecl())
15311515
GET_REFERRENT(PatternEntryDeclScope, getPattern())
15321516
GET_REFERRENT(TopLevelCodeScope, getDecl())
15331517
GET_REFERRENT(SubscriptDeclScope, getDecl())
1534-
GET_REFERRENT(VarDeclScope, getDecl())
15351518
GET_REFERRENT(GenericParamScope, paramList->getParams()[index])
15361519
GET_REFERRENT(AbstractStmtScope, getStmt())
15371520
GET_REFERRENT(CaptureListScope, getExpr())

lib/AST/ASTScopePrinting.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ void SubscriptDeclScope::printSpecifics(llvm::raw_ostream &out) const {
188188
decl->dumpRef(out);
189189
}
190190

191-
void VarDeclScope::printSpecifics(llvm::raw_ostream &out) const {
192-
decl->dumpRef(out);
193-
}
194-
195191
void ConditionalClausePatternUseScope::printSpecifics(
196192
llvm::raw_ostream &out) const {
197193
pattern->print(out);

lib/AST/ASTScopeSourceRange.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,6 @@ SourceRange PatternEntryInitializerScope::getSourceRangeOfThisASTNode(
258258
return initAsWrittenWhenCreated->getSourceRange();
259259
}
260260

261-
SourceRange
262-
VarDeclScope::getSourceRangeOfThisASTNode(const bool omitAssertions) const {
263-
const auto br = decl->getBracesRange();
264-
return br.isValid() ? br : decl->getSourceRange();
265-
}
266-
267261
SourceRange GenericParamScope::getSourceRangeOfThisASTNode(
268262
const bool omitAssertions) const {
269263
auto nOrE = holder;

0 commit comments

Comments
 (0)