[PCH] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM...
authorCameron Desrochers <cameron@moodycamel.com>
Wed, 20 Sep 2017 19:03:37 +0000 (19:03 +0000)
committerCameron Desrochers <cameron@moodycamel.com>
Wed, 20 Sep 2017 19:03:37 +0000 (19:03 +0000)
commit84fd064ef98b8f38426ac2e118717ec2b66fb87a
tree44140cdbd496938997931d049f71ac4adbf17cc2
parentd95ed959d8ab270808aeec8b31f06140e68834ea
[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
clang/include/clang/Frontend/PrecompiledPreamble.h
clang/include/clang/Lex/Lexer.h
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Frontend/PrecompiledPreamble.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/Preprocessor.cpp
clang/unittests/Frontend/PCHPreambleTest.cpp