Differential Revision: https://reviews.llvm.org/D66511
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369993
91177308-0d34-0410-b5e6-
96231b3b80d8
return lexDefault(Kind, Id.Name, First, End);
}
+static void skipUTF8ByteOrderMark(const char *&First, const char *const End) {
+ if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
+ First[2] == '\xbf')
+ First += 3;
+}
+
bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+ skipUTF8ByteOrderMark(First, End);
while (First != End)
if (lexPPLine(First, End))
return true;
--- /dev/null
+// Test UTF8 BOM at start of file\r
+// RUN: printf '\xef\xbb\xbf' > %t.c\r
+// RUN: echo '#ifdef TEST\n' >> %t.c\r
+// RUN: echo '#include <string>' >> %t.c\r
+// RUN: echo '#endif' >> %t.c\r
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 2>&1 | FileCheck %s\r
+\r
+// CHECK: #ifdef TEST\r
+// CHECK-NEXT: #include <string>\r
+// CHECK-NEXT: #endif\r