diff options
author | Alp Toker <alp@nuanti.com> | 2013-11-28 07:21:44 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-11-28 07:21:44 +0000 |
commit | 3dfeafd9dbd26b6c8caeab2510edb202020a0abe (patch) | |
tree | d9be0524086b8e2d5f6ee6f4a67bd048e7a10f3a /clang/lib/Rewrite | |
parent | 92720ab1b2b3b0769ba99d5f0169e927ac0bd4e2 (diff) | |
download | bcm5719-llvm-3dfeafd9dbd26b6c8caeab2510edb202020a0abe.tar.gz bcm5719-llvm-3dfeafd9dbd26b6c8caeab2510edb202020a0abe.zip |
InclusionRewriter: Avoid duplicated BOM check
The lexer already knows its position in the file, so use that instead of
guessing it might be 3.
llvm-svn: 195910
Diffstat (limited to 'clang/lib/Rewrite')
-rw-r--r-- | clang/lib/Rewrite/Frontend/InclusionRewriter.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp b/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp index 71ceb5f0b6a..176ea3f79dc 100644 --- a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp +++ b/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp @@ -363,15 +363,11 @@ bool InclusionRewriter::Process(FileID FileId, if (SM.getFileIDSize(FileId) == 0) return false; - // The next byte to be copied from the source file - unsigned NextToWrite = 0; + // The next byte to be copied from the source file, which may be non-zero if + // the lexer handled a BOM. + unsigned NextToWrite = SM.getFileOffset(RawLex.getSourceLocation()); int Line = 1; // The current input file line number. - // Ignore UTF-8 BOM, otherwise it'd end up somewhere else than the start - // of the resulting file. - if (FromFile.getBuffer().startswith("\xEF\xBB\xBF")) - NextToWrite = 3; - Token RawToken; RawLex.LexFromRawLexer(RawToken); |