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 | 3960540e305dd27dc20e5e038f499149ddf5c4db (patch) | |
tree | c4623be03b82b32c9992a9289bf4bfa082078ef3 /clang/lib/Serialization/ASTWriter.cpp | |
parent | 9ed4dbcb755281d16856dc2eef1326c18cace0b7 (diff) | |
download | bcm5719-llvm-3960540e305dd27dc20e5e038f499149ddf5c4db.tar.gz bcm5719-llvm-3960540e305dd27dc20e5e038f499149ddf5c4db.zip |
[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
llvm-svn: 170150
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index ed0a272faa0..1b39f551bf2 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/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(); |