Edit: Do not extend a removal to include trailing whitespace if we're at the end

of the file.

This would run past the end of the buffer. Sadly I don't have a great way to
test it, the only way to trigger the bug is having a removal fix it at the end
of the file, which none of our current warnings can generate.

llvm-svn: 217766
This commit is contained in:
Benjamin Kramer 2014-09-15 11:47:10 +00:00
parent 00b1e0fc9d
commit 1009df42c0
1 changed files with 6 additions and 0 deletions

View File

@ -280,6 +280,12 @@ static void adjustRemoval(const SourceManager &SM, const LangOptions &LangOpts,
unsigned begin = offs.getOffset();
unsigned end = begin + len;
// Do not try to extend the removal if we're at the end of the buffer already.
if (end == buffer.size())
return;
assert(begin < buffer.size() && end < buffer.size() && "Invalid range!");
// FIXME: Remove newline.
if (begin == 0) {