diff options
author | Cameron Desrochers <cameron@moodycamel.com> | 2017-09-20 19:03:37 +0000 |
---|---|---|
committer | Cameron Desrochers <cameron@moodycamel.com> | 2017-09-20 19:03:37 +0000 |
commit | 84fd064ef98b8f38426ac2e118717ec2b66fb87a (patch) | |
tree | 44140cdbd496938997931d049f71ac4adbf17cc2 /clang/lib/Lex/Preprocessor.cpp | |
parent | d95ed959d8ab270808aeec8b31f06140e68834ea (diff) | |
download | bcm5719-llvm-84fd064ef98b8f38426ac2e118717ec2b66fb87a.tar.gz bcm5719-llvm-84fd064ef98b8f38426ac2e118717ec2b66fb87a.zip |
[PCH] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)
This patch fixes broken preamble-skipping when the preamble region includes a byte order mark (BOM). Previously, parsing would fail if preamble PCH generation was enabled and a BOM was present.
This also fixes preamble invalidation when a BOM appears or disappears. This may seem to be an obscure edge case, but it happens regularly with IDEs that pass buffer overrides that never (or always) have a BOM, yet the underlying file from the initial parse that generated a PCH might (or might not) have a BOM.
I've included a test case for these scenarios.
Differential Revision: https://reviews.llvm.org/D37491
llvm-svn: 313796
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index e1294994df5..1f9a469bc59 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -516,9 +516,9 @@ void Preprocessor::EnterMainSourceFile() { // If we've been asked to skip bytes in the main file (e.g., as part of a // precompiled preamble), do so now. if (SkipMainFilePreamble.first > 0) - CurLexer->SkipBytes(SkipMainFilePreamble.first, - SkipMainFilePreamble.second); - + CurLexer->SetByteOffset(SkipMainFilePreamble.first, + SkipMainFilePreamble.second); + // Tell the header info that the main file was entered. If the file is later // #imported, it won't be re-entered. if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID)) |