Skip to content

Commit

Permalink
Merge pull request #75144 from rintaro/6.0-rangecontainsloc-optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
rintaro authored Jul 11, 2024
2 parents 2040bc7 + 2010dae commit 20b94d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/AST/TypeRefinementContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,13 @@ TypeRefinementContext::createForWhileStmtBody(ASTContext &Ctx, WhileStmt *S,
/// range.
static bool rangeContainsTokenLocWithGeneratedSource(
SourceManager &sourceMgr, SourceRange parentRange, SourceLoc childLoc) {
auto parentBuffer = sourceMgr.findBufferContainingLoc(parentRange.Start);
if (sourceMgr.rangeContainsTokenLoc(parentRange, childLoc))
return true;

auto childBuffer = sourceMgr.findBufferContainingLoc(childLoc);
while (parentBuffer != childBuffer) {
auto info = sourceMgr.getGeneratedSourceInfo(childBuffer);
while (!sourceMgr.rangeContainsTokenLoc(
sourceMgr.getRangeForBuffer(childBuffer), parentRange.Start)) {
auto *info = sourceMgr.getGeneratedSourceInfo(childBuffer);
if (!info)
return false;

Expand Down

0 comments on commit 20b94d2

Please sign in to comment.