aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/TranslationUnit.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-28 03:45:20 +0000
committerChris Lattner <sabre@nondot.org>2009-03-28 03:45:20 +0000
commita9376d470ccb0eac74fe09a6b2a18a890f1d17c4 (patch)
tree6dabcfdf008aadb82dea793ba2005c339e13d2b2 /lib/AST/TranslationUnit.cpp
parentaf3e3d54e990b385e5a653d2994d7d41427a13b8 (diff)
move serialization logic from TranslationUnit to ASTContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67902 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TranslationUnit.cpp')
-rw-r--r--lib/AST/TranslationUnit.cpp82
1 files changed, 2 insertions, 80 deletions
diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp
index ed84241df4..8ceada593e 100644
--- a/lib/AST/TranslationUnit.cpp
+++ b/lib/AST/TranslationUnit.cpp
@@ -26,9 +26,6 @@
using namespace clang;
-enum { BasicMetadataBlock = 1,
- ASTContextBlock = 2,
- DeclsBlock = 3 };
TranslationUnit::~TranslationUnit() {
if (OwnsMetaData && Context) {
@@ -79,7 +76,7 @@ bool clang::EmitASTBitcodeBuffer(const TranslationUnit& TU,
llvm::Serializer Sezr(Stream);
// Emit the translation unit.
- TU.Emit(Sezr);
+ TU.getContext().EmitAll(Sezr);
}
return true;
@@ -118,40 +115,6 @@ bool clang::EmitASTBitcodeFile(const TranslationUnit& TU,
return false;
}
-void TranslationUnit::Emit(llvm::Serializer& Sezr) const {
- // ===---------------------------------------------------===/
- // Serialize the "Translation Unit" metadata.
- // ===---------------------------------------------------===/
-
- // Emit ASTContext.
- Sezr.EnterBlock(ASTContextBlock);
- Sezr.EmitOwnedPtr(Context);
- Sezr.ExitBlock(); // exit "ASTContextBlock"
-
- Sezr.EnterBlock(BasicMetadataBlock);
-
- // Block for SourceManager and Target. Allows easy skipping
- // around to the block for the Selectors during deserialization.
- Sezr.EnterBlock();
-
- // Emit the SourceManager.
- Sezr.Emit(Context->getSourceManager());
-
- // Emit the Target.
- Sezr.EmitPtr(&Context->Target);
- Sezr.EmitCStr(Context->Target.getTargetTriple());
-
- Sezr.ExitBlock(); // exit "SourceManager and Target Block"
-
- // Emit the Selectors.
- Sezr.Emit(Context->Selectors);
-
- // Emit the Identifier Table.
- Sezr.Emit(Context->Idents);
-
- Sezr.ExitBlock(); // exit "BasicMetadataBlock"
-}
-
TranslationUnit*
clang::ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer, FileManager& FMgr) {
@@ -202,48 +165,7 @@ TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr,
// Create the translation unit object.
TranslationUnit* TU = new TranslationUnit();
- // ===---------------------------------------------------===/
- // Deserialize the "Translation Unit" metadata.
- // ===---------------------------------------------------===/
-
- // Skip to the BasicMetaDataBlock. First jump to ASTContextBlock
- // (which will appear earlier) and record its location.
-
- bool FoundBlock = Dezr.SkipToBlock(ASTContextBlock);
- assert (FoundBlock);
-
- llvm::Deserializer::Location ASTContextBlockLoc =
- Dezr.getCurrentBlockLocation();
-
- FoundBlock = Dezr.SkipToBlock(BasicMetadataBlock);
- assert (FoundBlock);
-
- // Read the SourceManager.
- SourceManager::CreateAndRegister(Dezr,FMgr);
-
- { // Read the TargetInfo.
- llvm::SerializedPtrID PtrID = Dezr.ReadPtrID();
- char* triple = Dezr.ReadCStr(NULL,0,true);
- Dezr.RegisterPtr(PtrID, TargetInfo::CreateTargetInfo(std::string(triple)));
- delete [] triple;
- }
-
- // For Selectors, we must read the identifier table first because the
- // SelectorTable depends on the identifiers being already deserialized.
- llvm::Deserializer::Location SelectorBlkLoc = Dezr.getCurrentBlockLocation();
- Dezr.SkipBlock();
-
- // Read the identifier table.
- IdentifierTable::CreateAndRegister(Dezr);
-
- // Now jump back and read the selectors.
- Dezr.JumpTo(SelectorBlkLoc);
- SelectorTable::CreateAndRegister(Dezr);
-
- // Now jump back to ASTContextBlock and read the ASTContext.
- Dezr.JumpTo(ASTContextBlockLoc);
- TU->Context = Dezr.ReadOwnedPtr<ASTContext>();
+ TU->Context = ASTContext.CreateAll(Dezr, FmMgr);
return TU;
}
-