forked from OSchip/llvm-project
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:
parent
92720ab1b2
commit
3dfeafd9db
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue