diff options
Diffstat (limited to 'clang/lib/AST/TranslationUnit.cpp')
-rw-r--r-- | clang/lib/AST/TranslationUnit.cpp | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/clang/lib/AST/TranslationUnit.cpp b/clang/lib/AST/TranslationUnit.cpp index 57f9f4ebc80..0c69432014d 100644 --- a/clang/lib/AST/TranslationUnit.cpp +++ b/clang/lib/AST/TranslationUnit.cpp @@ -29,68 +29,3 @@ using namespace clang; TranslationUnit::~TranslationUnit() { } - -bool clang::EmitASTBitcodeBuffer(const ASTContext &Ctx, - std::vector<unsigned char>& Buffer) { - // 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. Placing it in its own scope assures any necessary - // finalization of bits to the buffer in the serializer's dstor. - llvm::Serializer Sezr(Stream); - - // Emit the translation unit. - Ctx.EmitAll(Sezr); - } - - return true; -} - -TranslationUnit* -clang::ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer, FileManager& FMgr) { - - // Check if the file is of the proper length. - if (MBuffer.getBufferSize() & 0x3) { - // FIXME: Provide diagnostic: "Length should be a multiple of 4 bytes." - return NULL; - } - - // Create the bitstream reader. - unsigned char *BufPtr = (unsigned char *) MBuffer.getBufferStart(); - llvm::BitstreamReader Stream(BufPtr,BufPtr+MBuffer.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); - - return TranslationUnit::Create(Dezr,FMgr); -} - -TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr, - FileManager& FMgr) { - - // Create the translation unit object. - TranslationUnit* TU = new TranslationUnit(); - - TU->Context = ASTContext::CreateAll(Dezr, FMgr); - - return TU; -} |