Skip to content

Commit a4487f6

Browse files
committed
AST: Use SourceManager::containsTokenLoc() in TypeRefinementContext.cpp.
The existing `rangeContainsTokenLocWithGeneratedSource()` utility pre-dated `SourceManager::containsTokenLoc()`.
1 parent 23b721f commit a4487f6

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

lib/AST/TypeRefinementContext.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -169,37 +169,12 @@ TypeRefinementContext::createForWhileStmtBody(ASTContext &Ctx, WhileStmt *S,
169169
Ctx, S, Parent, S->getBody()->getSourceRange(), Info, /* ExplicitInfo */Info);
170170
}
171171

172-
/// Determine whether the child location is somewhere within the parent
173-
/// range.
174-
static bool rangeContainsTokenLocWithGeneratedSource(
175-
SourceManager &sourceMgr, SourceRange parentRange, SourceLoc childLoc) {
176-
if (sourceMgr.rangeContainsTokenLoc(parentRange, childLoc))
177-
return true;
178-
179-
auto childBuffer = sourceMgr.findBufferContainingLoc(childLoc);
180-
while (!sourceMgr.rangeContainsTokenLoc(
181-
sourceMgr.getRangeForBuffer(childBuffer), parentRange.Start)) {
182-
auto *info = sourceMgr.getGeneratedSourceInfo(childBuffer);
183-
if (!info)
184-
return false;
185-
186-
childLoc = info->originalSourceRange.getStart();
187-
if (childLoc.isInvalid())
188-
return false;
189-
190-
childBuffer = sourceMgr.findBufferContainingLoc(childLoc);
191-
}
192-
193-
return sourceMgr.rangeContainsTokenLoc(parentRange, childLoc);
194-
}
195-
196172
TypeRefinementContext *
197173
TypeRefinementContext::findMostRefinedSubContext(SourceLoc Loc,
198174
ASTContext &Ctx) {
199175
assert(Loc.isValid());
200176

201-
if (SrcRange.isValid() &&
202-
!rangeContainsTokenLocWithGeneratedSource(Ctx.SourceMgr, SrcRange, Loc))
177+
if (SrcRange.isValid() && !Ctx.SourceMgr.containsTokenLoc(SrcRange, Loc))
203178
return nullptr;
204179

205180
auto expandedChildren = evaluateOrDefault(

0 commit comments

Comments
 (0)