diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-30 22:46:56 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-30 22:46:56 +0000 |
commit | bdbb285aed1bb1e20090a16929f4c1da33d2d5c5 (patch) | |
tree | 382aa4763cb99e5964ccbf8f5b1467f31f357dd5 /Driver/SerializationTest.cpp | |
parent | e365c50a21cb02e0219433db0c4461566ad4a597 (diff) |
Implemented serialization of SelectorTable and Selectors.
Modified serialization of IdentifierTable to self-register itself with
the Deserializer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/SerializationTest.cpp')
-rw-r--r-- | Driver/SerializationTest.cpp | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/Driver/SerializationTest.cpp b/Driver/SerializationTest.cpp index 9beb92e130..f8d4b7820e 100644 --- a/Driver/SerializationTest.cpp +++ b/Driver/SerializationTest.cpp @@ -53,9 +53,9 @@ class SerializationTest : public ASTConsumer { ASTContext* Context; std::list<Decl*> Decls; - enum { BasicMetadataBlock, - ASTContextBlock, - DeclsBlock }; + enum { BasicMetadataBlock = 1, + ASTContextBlock = 2, + DeclsBlock = 3 }; public: SerializationTest() : Context(NULL) {}; @@ -163,6 +163,10 @@ void SerializationTest::Serialize(llvm::sys::Path& Filename, Sezr.EnterBlock(BasicMetadataBlock); + // Block for SourceManager and Target. Allows easy skipping around + // to the Selectors during deserialization. + Sezr.EnterBlock(); + // "Fake" emit the SourceManager. llvm::cerr << "Faux-serializing: SourceManager.\n"; Sezr.EmitPtr(&Context->SourceMgr); @@ -171,13 +175,15 @@ void SerializationTest::Serialize(llvm::sys::Path& Filename, llvm::cerr << "Faux-serializing: Target.\n"; Sezr.EmitPtr(&Context->Target); - // "Fake" emit Selectors. - llvm::cerr << "Faux-serializing: Selectors.\n"; - Sezr.EmitPtr(&Context->Selectors); + Sezr.ExitBlock(); + + // Emit the Selectors. + llvm::cerr << "Serializing: Selectors.\n"; + Sezr.Emit(Context->Selectors); // Emit the Identifier Table. llvm::cerr << "Serializing: IdentifierTable.\n"; - Sezr.EmitOwnedPtr(&Context->Idents); + Sezr.Emit(Context->Idents); Sezr.ExitBlock(); @@ -254,19 +260,23 @@ void SerializationTest::Deserialize(llvm::sys::Path& Filename, llvm::cerr << "Faux-Deserializing: Target.\n"; Dezr.RegisterPtr(&Context->Target); - // "Fake" read the Selectors. - llvm::cerr << "Faux-Deserializing: Selectors.\n"; - Dezr.RegisterPtr(&Context->Selectors); + // For Selectors, we must read the identifier table first because the + // SelectorTable depends on the identifiers being already deserialized. + llvm::Deserializer::Location SelectorBlockLoc = Dezr.getCurrentBlockLocation(); + Dezr.SkipBlock(); // Read the identifier table. llvm::cerr << "Deserializing: IdentifierTable\n"; - Dezr.ReadOwnedPtr<IdentifierTable>(); + IdentifierTable::CreateAndRegister(Dezr); - // Now jump back to ASTContextBlock and read the ASTContext. - Dezr.JumpTo(ASTContextBlockLoc); + // Now jump back and read the selectors. + llvm::cerr << "Deserializing: Selectors\n"; + Dezr.JumpTo(SelectorBlockLoc); + SelectorTable::CreateAndRegister(Dezr); - // Read the ASTContext. + // Now jump back to ASTContextBlock and read the ASTContext. llvm::cerr << "Deserializing: ASTContext.\n"; + Dezr.JumpTo(ASTContextBlockLoc); Dezr.ReadOwnedPtr<ASTContext>(); // "Rewind" the stream. Find the block with the serialized top-level decls. |