]> granicus.if.org Git - clang/commitdiff
eliminate ReadASTBitcodeFile
authorChris Lattner <sabre@nondot.org>
Sat, 28 Mar 2009 03:49:26 +0000 (03:49 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 28 Mar 2009 03:49:26 +0000 (03:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67903 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/TranslationUnit.h
lib/AST/TranslationUnit.cpp
tools/clang-cc/SerializationTest.cpp
tools/clang-cc/clang.cpp

index 5fff66626b1eac5af089da33a4a56e54e97c04b7..3c6344f2d98532277cff4f3ebbafbaabf9200c49 100644 (file)
@@ -82,10 +82,6 @@ bool EmitASTBitcodeBuffer(const TranslationUnit& TU,
 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); 
index 8ceada593ede256e489585d0b80b0710a4c7c2a6..a0a800c1e31490be68f1a26d12085c3dd8278220 100644 (file)
@@ -144,28 +144,13 @@ clang::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;
 }
index e489a19ff83ff0c180dd642befd3d6a975fd88a2..fcc047e0156bea3b0854ea87dfcc2a0c44b987df 100644 (file)
@@ -81,7 +81,18 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename,
                                     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;
index 7f46f46fed7ba428500eedc2dbe35ac9d08d4d2c..9bd6dfb805f1f41724b81bc1a2153ab4c7af4ea0 100644 (file)
@@ -1535,7 +1535,14 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
     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",