diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-15 11:47:10 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-15 11:47:10 +0000 |
| commit | 1009df42c0f8089e3f7c13d37a9b1d861710729e (patch) | |
| tree | 42ec5bf11d7f90c59854ac28943aac7a7cfe4a48 /clang/lib/Edit | |
| parent | 00b1e0fc9dd1956db20bd2b1568efd063f32c54d (diff) | |
| download | bcm5719-llvm-1009df42c0f8089e3f7c13d37a9b1d861710729e.tar.gz bcm5719-llvm-1009df42c0f8089e3f7c13d37a9b1d861710729e.zip | |
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
Diffstat (limited to 'clang/lib/Edit')
| -rw-r--r-- | clang/lib/Edit/EditedSource.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Edit/EditedSource.cpp b/clang/lib/Edit/EditedSource.cpp index 6cf6335da18..1c66cb82770 100644 --- a/clang/lib/Edit/EditedSource.cpp +++ b/clang/lib/Edit/EditedSource.cpp @@ -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) { |

