bool EmitASTBitcodeBuffer(const TranslationUnit* TU,
std::vector<unsigned char>& Buffer);
-/// ReadASTBitcodeFile - Reconsitute a translation unit from a bitcode file.
-TranslationUnit* ReadASTBitcodeFile(const llvm::sys::Path& Filename,
- FileManager& FMgr);
-
/// ReadASTBitcodeBuffer - Reconsitute a translation unit from a buffer.
TranslationUnit* ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer,
FileManager& FMgr);
return TranslationUnit::Create(Dezr,FMgr);
}
-TranslationUnit*
-clang::ReadASTBitcodeFile(const llvm::sys::Path& Filename, FileManager& FMgr) {
-
- // Create the memory buffer that contains the contents of the file.
- llvm::OwningPtr<llvm::MemoryBuffer>
- MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str()));
-
- if (!MBuffer) {
- // FIXME: Provide diagnostic.
- return NULL;
- }
-
- return ReadASTBitcodeBuffer(*MBuffer, FMgr);
-}
-
TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr,
FileManager& FMgr) {
// Create the translation unit object.
TranslationUnit* TU = new TranslationUnit();
- TU->Context = ASTContext.CreateAll(Dezr, FmMgr);
+ TU->Context = ASTContext::CreateAll(Dezr, FMgr);
return TU;
}
llvm::sys::Path& FNameDeclPrint) {
// Deserialize the translation unit.
- TranslationUnit* NewTU = ReadASTBitcodeFile(Filename, FMgr);
+ TranslationUnit* NewTU;
+
+ {
+ // Create the memory buffer that contains the contents of the file.
+ llvm::OwningPtr<llvm::MemoryBuffer>
+ MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str()));
+
+ if (!MBuffer)
+ return false;
+
+ NewTU = ReadASTBitcodeBuffer(*MBuffer, FMgr);
+ }
if (!NewTU)
return false;
exit (1);
}
- llvm::OwningPtr<TranslationUnit> TU(ReadASTBitcodeFile(Filename, FileMgr));
+ llvm::OwningPtr<TranslationUnit> TU;
+
+ // Create the memory buffer that contains the contents of the file.
+ llvm::OwningPtr<llvm::MemoryBuffer>
+ MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str()));
+
+ if (MBuffer)
+ TU.reset(ReadASTBitcodeBuffer(*MBuffer, FileMgr));
if (!TU) {
fprintf(stderr, "error: file '%s' could not be deserialized\n",