In location -> source file mapping, handle empty buffers gracefully

This commit is contained in:
Doug Gregor
2023-03-01 17:12:42 -08:00
parent 45a09796b9
commit ee3bcf262b

View File

@@ -640,7 +640,7 @@ SourceFile *ModuleDecl::getSourceFileContainingLocation(SourceLoc loc) {
auto foundSourceFile = *found;
auto foundRange = sourceMgr.getRangeForBuffer(*foundSourceFile->getBufferID());
if (!foundRange.contains(adjustedLoc))
if (!foundRange.contains(adjustedLoc) && adjustedLoc != foundRange.getStart())
return nullptr;
// Update the last source file.