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 <[email protected]> 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 > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
