summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite
diff options
context:
space:
mode:
authorLubos Lunak <l.lunak@suse.cz>2013-11-27 21:14:43 +0000
committerLubos Lunak <l.lunak@suse.cz>2013-11-27 21:14:43 +0000
commitc6b9270d047e07718586aca4825fe958c1850345 (patch)
treecd5b82c6537ce6ca4c86f2bc031ff3f5345950c7 /clang/lib/Rewrite
parent72e5b93b821fabc022aae20b0b5ae8b94cf4f4cc (diff)
downloadbcm5719-llvm-c6b9270d047e07718586aca4825fe958c1850345.tar.gz
bcm5719-llvm-c6b9270d047e07718586aca4825fe958c1850345.zip
strip UTF-8 BOM in -frewrite-includes (PR#15664)
llvm-svn: 195877
Diffstat (limited to 'clang/lib/Rewrite')
-rw-r--r--clang/lib/Rewrite/Frontend/InclusionRewriter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp b/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp
index bd4250adaad..71ceb5f0b6a 100644
--- a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp
+++ b/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp
@@ -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);
OpenPOWER on IntegriCloud