forked from OSchip/llvm-project
[clang-scan-deps] Skip UTF-8 BOM in source minimizer
Differential Revision: https://reviews.llvm.org/D66511 llvm-svn: 369993
This commit is contained in:
parent
a8e8dd91f0
commit
e6561e0068
|
@ -834,7 +834,14 @@ bool Minimizer::lexPPLine(const char *&First, const char *const End) {
|
|||
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;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// Test UTF8 BOM at start of file
|
||||
// RUN: printf '\xef\xbb\xbf' > %t.c
|
||||
// RUN: echo '#ifdef TEST\n' >> %t.c
|
||||
// RUN: echo '#include <string>' >> %t.c
|
||||
// RUN: echo '#endif' >> %t.c
|
||||
// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 2>&1 | FileCheck %s
|
||||
|
||||
// CHECK: #ifdef TEST
|
||||
// CHECK-NEXT: #include <string>
|
||||
// CHECK-NEXT: #endif
|
Loading…
Reference in New Issue