Skip to content

Commit 20b94d2

Browse files
authored
Merge pull request swiftlang#75144 from rintaro/6.0-rangecontainsloc-optimize
2 parents 2040bc7 + 2010dae commit 20b94d2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/AST/TypeRefinementContext.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,13 @@ TypeRefinementContext::createForWhileStmtBody(ASTContext &Ctx, WhileStmt *S,
181181
/// range.
182182
static bool rangeContainsTokenLocWithGeneratedSource(
183183
SourceManager &sourceMgr, SourceRange parentRange, SourceLoc childLoc) {
184-
auto parentBuffer = sourceMgr.findBufferContainingLoc(parentRange.Start);
184+
if (sourceMgr.rangeContainsTokenLoc(parentRange, childLoc))
185+
return true;
186+
185187
auto childBuffer = sourceMgr.findBufferContainingLoc(childLoc);
186-
while (parentBuffer != childBuffer) {
187-
auto info = sourceMgr.getGeneratedSourceInfo(childBuffer);
188+
while (!sourceMgr.rangeContainsTokenLoc(
189+
sourceMgr.getRangeForBuffer(childBuffer), parentRange.Start)) {
190+
auto *info = sourceMgr.getGeneratedSourceInfo(childBuffer);
188191
if (!info)
189192
return false;
190193

0 commit comments

Comments
 (0)