diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-13 21:38:23 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-13 21:38:23 +0000 |
commit | 5e24f2d83099bb557b1d39c6420787eeaf072a81 (patch) | |
tree | f5d84c95c272df59f339ee4d63878468359a5999 /lib/Serialization/ASTWriter.cpp | |
parent | de39d1752f1559060237f158e47af6527d5e4abe (diff) |
[PCH] Make the new PCH format (control block) backwards compatible and
don't crash when loading a PCH with the older format.
The introduction of the control block broke compatibility with PCHs from
older versions. This patch allows loading (and rejecting) PCHs from an older
version and allows newer PCHs to be rejected from older clang versions as well.
rdar://12821386
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index ed0a272faa..1b39f551bf 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3568,6 +3568,12 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, RecordData Record; Stream.EnterSubblock(AST_BLOCK_ID, 5); + // This is so that older clang versions, before the introduction + // of the control block, can read and reject the newer PCH format. + Record.clear(); + Record.push_back(VERSION_MAJOR); + Stream.EmitRecord(METADATA_OLD_FORMAT, Record); + // Create a lexical update block containing all of the declarations in the // translation unit that do not come from other AST files. const TranslationUnitDecl *TU = Context.getTranslationUnitDecl(); |