<div dir="ltr">This seems like it has the side effect of trimming leading whitespace from the rewritten file, but that's probably fine.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 27, 2013 at 11:21 PM, Alp Toker <span dir="ltr"><<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: alp<br>
Date: Thu Nov 28 01:21:44 2013<br>
New Revision: 195910<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=195910&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=195910&view=rev</a><br>
Log:<br>
InclusionRewriter: Avoid duplicated BOM check<br>
<br>
The lexer already knows its position in the file, so use that instead of<br>
guessing it might be 3.<br>
<br>
Modified:<br>
cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp<br>
<br>
Modified: cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=195910&r1=195909&r2=195910&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=195910&r1=195909&r2=195910&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)<br>
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Thu Nov 28 01:21:44 2013<br>
@@ -363,15 +363,11 @@ bool InclusionRewriter::Process(FileID F<br>
if (SM.getFileIDSize(FileId) == 0)<br>
return false;<br>
<br>
- // The next byte to be copied from the source file<br>
- unsigned NextToWrite = 0;<br>
+ // The next byte to be copied from the source file, which may be non-zero if<br>
+ // the lexer handled a BOM.<br>
+ unsigned NextToWrite = SM.getFileOffset(RawLex.getSourceLocation());<br>
int Line = 1; // The current input file line number.<br>
<br>
- // Ignore UTF-8 BOM, otherwise it'd end up somewhere else than the start<br>
- // of the resulting file.<br>
- if (FromFile.getBuffer().startswith("\xEF\xBB\xBF"))<br>
- NextToWrite = 3;<br>
-<br>
Token RawToken;<br>
RawLex.LexFromRawLexer(RawToken);<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>