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/Frontend | |
| 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/Frontend')
| -rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Frontend/PrecompiledPreamble.cpp | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 3e3483d2c6b..86460f17d0f 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -591,7 +591,7 @@ void PrintPreambleAction::ExecuteAction() { auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile()); if (Buffer) { unsigned Preamble = - Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).first; + Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size; llvm::outs().write((*Buffer)->getBufferStart(), Preamble); } } diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp index cd7446189cc..bd6770acdff 100644 --- a/clang/lib/Frontend/PrecompiledPreamble.cpp +++ b/clang/lib/Frontend/PrecompiledPreamble.cpp @@ -195,8 +195,7 @@ template <class T> bool moveOnNoError(llvm::ErrorOr<T> Val, T &Output) { PreambleBounds clang::ComputePreambleBounds(const LangOptions &LangOpts, llvm::MemoryBuffer *Buffer, unsigned MaxLines) { - auto Pre = Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines); - return PreambleBounds(Pre.first, Pre.second); + return Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines); } llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build( |

