------------------------------------------------------------------------
r195877 | llunak | 2013-11-27 13:14:43 -0800 (Wed, 27 Nov 2013) | 3 lines
strip UTF-8 BOM in -frewrite-includes (PR#15664)
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@195987
91177308-0d34-0410-b5e6-
96231b3b80d8
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);
--- /dev/null
+// This file starts with UTF-8 BOM marker.
--- /dev/null
+// 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"