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 | ef8a6dcd09a9c747032a609303878b2e06d1e9e2 (patch) | |
| tree | e294333b953b642a9360c780dbe982a94fb3ab12 /clang-tools-extra/change-namespace/ChangeNamespace.cpp | |
| parent | 86b3a1e79baf4f0d422ecd9c5fd67e7d04bbf697 (diff) | |
| download | bcm5719-llvm-ef8a6dcd09a9c747032a609303878b2e06d1e9e2.tar.gz bcm5719-llvm-ef8a6dcd09a9c747032a609303878b2e06d1e9e2.zip | |
[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
llvm-svn: 283210
Diffstat (limited to 'clang-tools-extra/change-namespace/ChangeNamespace.cpp')
| -rw-r--r-- | clang-tools-extra/change-namespace/ChangeNamespace.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang-tools-extra/change-namespace/ChangeNamespace.cpp b/clang-tools-extra/change-namespace/ChangeNamespace.cpp index 274c9acf4d0..15ce4edaaa5 100644 --- a/clang-tools-extra/change-namespace/ChangeNamespace.cpp +++ b/clang-tools-extra/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 |

