diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-28 04:27:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-28 04:27:18 +0000 |
commit | 557c5b1717bc8919b1b40cf2064b51491ec53a44 (patch) | |
tree | a04e5fd895bcb02ab9f2c183d68653effe9a56a7 /lib/AST/TranslationUnit.cpp | |
parent | 14734f7d2a69f9076e8a06954f06d3313063e7f9 (diff) |
push more ASTContext goodness out through interfaces that use
TranslationUnit
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67913 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TranslationUnit.cpp')
-rw-r--r-- | lib/AST/TranslationUnit.cpp | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp index 57f9f4ebc8..0c69432014 100644 --- a/lib/AST/TranslationUnit.cpp +++ b/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; -} |