diff options
| author | Haojian Wu <hokein@google.com> | 2016-10-04 10:35:53 +0000 |
|---|---|---|
| committer | Haojian Wu <hokein@google.com> | 2016-10-04 10:35:53 +0000 |
| commit | 0ea92a69bca1c674273f0951a12bba6a3d8b96c5 (patch) | |
| tree | 390dd329d94f0ec776477dc0dc1347d965c13ebd /change-namespace | |
| parent | dd5cc8b7a51c47c4bfcfcf898164851e89fe0a3b (diff) | |
[change-namespace] Fix a misplaced case when there is no trailing newline character at the end of the file.
Reviewers: ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25226
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@283210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'change-namespace')
| -rw-r--r-- | change-namespace/ChangeNamespace.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/change-namespace/ChangeNamespace.cpp b/change-namespace/ChangeNamespace.cpp index 274c9acf..15ce4eda 100644 --- a/change-namespace/ChangeNamespace.cpp +++ b/change-namespace/ChangeNamespace.cpp @@ -106,8 +106,9 @@ SourceLocation getStartOfNextLine(SourceLocation Loc, const SourceManager &SM, // FIXME: this is a bit hacky to get ReadToEndOfLine work. Lex.setParsingPreprocessorDirective(true); Lex.ReadToEndOfLine(&Line); - // FIXME: should not +1 at EOF. - return Loc.getLocWithOffset(Line.size() + 1); + auto End = Loc.getLocWithOffset(Line.size()); + return SM.getLocForEndOfFile(LocInfo.first) == End ? End + : End.getLocWithOffset(1); } // Returns `R` with new range that refers to code after `Replaces` being |
