Skip to content

Commit

Permalink
Edit: Do not extend a removal to include trailing whitespace if we're…
Browse files Browse the repository at this point in the history
… 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217766 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed Sep 15, 2014
1 parent 04fdc2f commit 0454256
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Edit/EditedSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0454256

Please sign in to comment.