Skip to content

Commit b720c04

Browse files
committed
ASTScope: Simplify a couple of getSourceRangeOfThisASTNode() methods
1 parent 885f6eb commit b720c04

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ class ParameterListScope final : public ASTScopeImpl {
797797

798798
private:
799799
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
800-
SourceLoc fixupEndForBadInput(SourceRange) const;
801800

802801
public:
803802
std::string getClassName() const override;

lib/AST/ASTScopeSourceRange.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,14 @@ SourceRange AbstractStmtScope::getSourceRangeOfThisASTNode(
128128

129129
SourceRange DefaultArgumentInitializerScope::getSourceRangeOfThisASTNode(
130130
const bool omitAssertions) const {
131-
if (auto *dv = decl->getStructuralDefaultExpr())
132-
return dv->getSourceRange();
133-
return SourceRange();
131+
return decl->getStructuralDefaultExpr()->getSourceRange();
134132
}
135133

136134
SourceRange PatternEntryDeclScope::getSourceRangeOfThisASTNode(
137135
const bool omitAssertions) const {
138136
SourceRange range = getPatternEntry().getSourceRange();
139-
if (endLoc.hasValue()) {
140-
ASTScopeAssert(endLoc->isValid(),
141-
"BraceStmt ends before pattern binding entry?");
137+
if (endLoc.hasValue())
142138
range.End = *endLoc;
143-
}
144139
return range;
145140
}
146141

@@ -244,20 +239,7 @@ SourceRange AbstractFunctionDeclScope::getSourceRangeOfThisASTNode(
244239

245240
SourceRange ParameterListScope::getSourceRangeOfThisASTNode(
246241
const bool omitAssertions) const {
247-
auto rangeForGoodInput = params->getSourceRange();
248-
auto r = SourceRange(rangeForGoodInput.Start,
249-
fixupEndForBadInput(rangeForGoodInput));
250-
ASTScopeAssert(getSourceManager().rangeContains(
251-
getParent().get()->getSourceRangeOfThisASTNode(true), r),
252-
"Parameters not within function?!");
253-
return r;
254-
}
255-
256-
SourceLoc ParameterListScope::fixupEndForBadInput(
257-
const SourceRange rangeForGoodInput) const {
258-
const auto s = rangeForGoodInput.Start;
259-
const auto e = rangeForGoodInput.End;
260-
return getSourceManager().isBeforeInBuffer(s, e) ? e : s;
242+
return params->getSourceRange();
261243
}
262244

263245
SourceRange ForEachPatternScope::getSourceRangeOfThisASTNode(

0 commit comments

Comments
 (0)