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
This commit is contained in:
Alp Toker 2013-11-28 07:21:44 +00:00
parent 92720ab1b2
commit 3dfeafd9db
1 changed files with 3 additions and 7 deletions

View File

@ -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);