strip UTF-8 BOM in -frewrite-includes (PR#15664)

llvm-svn: 195877
This commit is contained in:
Lubos Lunak 2013-11-27 21:14:43 +00:00
parent 72e5b93b82
commit c6b9270d04
3 changed files with 10 additions and 0 deletions

View File

@ -367,6 +367,11 @@ bool InclusionRewriter::Process(FileID FileId,
unsigned NextToWrite = 0;
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);

View File

@ -0,0 +1 @@
// This file starts with UTF-8 BOM marker.

View File

@ -0,0 +1,4 @@
// RUN: %clang -E -frewrite-includes -I %S/Inputs %s -o - | %clang -fsyntax-only -Xclang -verify -x c -
// expected-no-diagnostics
#include "rewrite-includes-bom.h"