r195910 - InclusionRewriter: Avoid duplicated BOM check
Alp Toker
alp at nuanti.com
Wed Nov 27 23:21:44 PST 2013
Author: alp
Date: Thu Nov 28 01:21:44 2013
New Revision: 195910
URL: http://llvm.org/viewvc/llvm-project?rev=195910&view=rev
Log:
InclusionRewriter: Avoid duplicated BOM check
The lexer already knows its position in the file, so use that instead of
guessing it might be 3.
Modified:
cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
Modified: cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=195910&r1=195909&r2=195910&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Thu Nov 28 01:21:44 2013
@@ -363,15 +363,11 @@ bool InclusionRewriter::Process(FileID F
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);
More information about the cfe-commits
mailing list