summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp178
1 files changed, 0 insertions, 178 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 159110a0800..a855ecf6b30 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -21,8 +21,6 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
-#include "llvm/Bitcode/Serialize.h"
-#include "llvm/Bitcode/Deserialize.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
using namespace clang;
@@ -3223,182 +3221,6 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) {
}
}
-
-//===----------------------------------------------------------------------===//
-// Serialization Support
-//===----------------------------------------------------------------------===//
-
-enum {
- BasicMetadataBlock = 1,
- ASTContextBlock = 2,
- DeclsBlock = 3
-};
-
-void ASTContext::EmitASTBitcodeBuffer(std::vector<unsigned char> &Buffer) const{
- // Create bitstream.
- llvm::BitstreamWriter Stream(Buffer);
-
- // Emit the preamble.
- Stream.Emit((unsigned)'B', 8);
- Stream.Emit((unsigned)'C', 8);
- Stream.Emit(0xC, 4);
- Stream.Emit(0xF, 4);
- Stream.Emit(0xE, 4);
- Stream.Emit(0x0, 4);
-
- // Create serializer.
- llvm::Serializer S(Stream);
-
- // ===---------------------------------------------------===/
- // Serialize the "Translation Unit" metadata.
- // ===---------------------------------------------------===/
-
- // Emit ASTContext.
- S.EnterBlock(ASTContextBlock);
- S.EmitOwnedPtr(this);
- S.ExitBlock(); // exit "ASTContextBlock"
-
- S.EnterBlock(BasicMetadataBlock);
-
- // Block for SourceManager and Target. Allows easy skipping
- // around to the block for the Selectors during deserialization.
- S.EnterBlock();
-
- // Emit the SourceManager.
- S.Emit(getSourceManager());
-
- // Emit the Target.
- S.EmitPtr(&Target);
- S.EmitCStr(Target.getTargetTriple());
-
- S.ExitBlock(); // exit "SourceManager and Target Block"
-
- // Emit the Selectors.
- S.Emit(Selectors);
-
- // Emit the Identifier Table.
- S.Emit(Idents);
-
- S.ExitBlock(); // exit "BasicMetadataBlock"
-}
-
-
-/// Emit - Serialize an ASTContext object to Bitcode.
-void ASTContext::Emit(llvm::Serializer& S) const {
- S.Emit(LangOpts);
- S.EmitRef(SourceMgr);
- S.EmitRef(Target);
- S.EmitRef(Idents);
- S.EmitRef(Selectors);
-
- // Emit the size of the type vector so that we can reserve that size
- // when we reconstitute the ASTContext object.
- S.EmitInt(Types.size());
-
- for (std::vector<Type*>::const_iterator I=Types.begin(), E=Types.end();
- I!=E;++I)
- (*I)->Emit(S);
-
- S.EmitOwnedPtr(TUDecl);
-
- // FIXME: S.EmitOwnedPtr(CFConstantStringTypeDecl);
-}
-
-
-ASTContext *ASTContext::ReadASTBitcodeBuffer(llvm::MemoryBuffer &Buffer,
- FileManager &FMgr) {
- // Check if the file is of the proper length.
- if (Buffer.getBufferSize() & 0x3) {
- // FIXME: Provide diagnostic: "Length should be a multiple of 4 bytes."
- return 0;
- }
-
- // Create the bitstream reader.
- unsigned char *BufPtr = (unsigned char *)Buffer.getBufferStart();
- llvm::BitstreamReader Stream(BufPtr, BufPtr+Buffer.getBufferSize());
-
- if (Stream.Read(8) != 'B' ||
- Stream.Read(8) != 'C' ||
- Stream.Read(4) != 0xC ||
- Stream.Read(4) != 0xF ||
- Stream.Read(4) != 0xE ||
- Stream.Read(4) != 0x0) {
- // FIXME: Provide diagnostic.
- return NULL;
- }
-
- // Create the deserializer.
- llvm::Deserializer Dezr(Stream);
-
- // ===---------------------------------------------------===/
- // 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);
- return Dezr.ReadOwnedPtr<ASTContext>();
-}
-
-ASTContext* ASTContext::Create(llvm::Deserializer& D) {
-
- // Read the language options.
- LangOptions LOpts;
- LOpts.Read(D);
-
- SourceManager &SM = D.ReadRef<SourceManager>();
- TargetInfo &t = D.ReadRef<TargetInfo>();
- IdentifierTable &idents = D.ReadRef<IdentifierTable>();
- SelectorTable &sels = D.ReadRef<SelectorTable>();
-
- unsigned size_reserve = D.ReadInt();
-
- ASTContext* A = new ASTContext(LOpts, SM, t, idents, sels,
- size_reserve);
-
- for (unsigned i = 0; i < size_reserve; ++i)
- Type::Create(*A,i,D);
-
- A->TUDecl = cast<TranslationUnitDecl>(D.ReadOwnedPtr<Decl>(*A));
-
- // FIXME: A->CFConstantStringTypeDecl = D.ReadOwnedPtr<RecordDecl>();
-
- return A;
-}
-
ExternalASTSource::~ExternalASTSource() { }
void ExternalASTSource::PrintStats() { }
OpenPOWER on IntegriCloud