r195910 - InclusionRewriter: Avoid duplicated BOM check
Reid Kleckner
rnk at google.com
Mon Dec 2 17:32:17 PST 2013
This seems like it has the side effect of trimming leading whitespace from
the rewritten file, but that's probably fine.
On Wed, Nov 27, 2013 at 11:21 PM, Alp Toker <alp at nuanti.com> wrote:
> 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);
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131202/3d2c91bc/attachment.html>
More information about the cfe-commits
mailing list