Skip to content

Commit 5d87a66

Browse files
author
David Ungar
committed
Ensure that after pushing start of ExtensionScope after extended type, the end is not before the beginning.
1 parent 3c891f9 commit 5d87a66

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/AST/ASTScopeSourceRange.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,12 @@ SourceRange GenericTypeOrExtensionWholePortion::getChildlessSourceRangeOf(
309309

310310
SourceRange
311311
ExtensionScope::moveStartPastExtendedNominal(const SourceRange sr) const {
312-
return SourceRange(getLocAfterExtendedNominal(decl), sr.End);
312+
const auto start = getLocAfterExtendedNominal(decl);
313+
// Illegal code can have an endLoc that is before the end of the
314+
// ExtendedNominal, so push the end back, too, in that case.
315+
const auto end =
316+
getSourceManager().isBeforeInBuffer(sr.End, start) ? start : sr.End;
317+
return SourceRange(start, end);
313318
}
314319

315320
SourceRange

0 commit comments

Comments
 (0)