summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2019-08-27 00:13:52 +0000
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>2019-08-27 00:13:52 +0000
commite6561e00684eb33d66bfbe165e918f8686958ef1 (patch)
tree6c1423d9fd0ada178c05de6969a4d5e350dff5ed /clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
parenta8e8dd91f06c0798f0bd615349c38ff7a7c395cc (diff)
downloadbcm5719-llvm-e6561e00684eb33d66bfbe165e918f8686958ef1.tar.gz
bcm5719-llvm-e6561e00684eb33d66bfbe165e918f8686958ef1.zip
[clang-scan-deps] Skip UTF-8 BOM in source minimizer
Differential Revision: https://reviews.llvm.org/D66511 llvm-svn: 369993
Diffstat (limited to 'clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp')
-rw-r--r--clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp b/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
index 265a6e44e33..a350481df9a 100644
--- a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ b/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -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;
OpenPOWER on IntegriCloud