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

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

index 3c6344f2d98532277cff4f3ebbafbaabf9200c49..40513e2019b8107451bd95cf7b8f93db4c935380 100644 (file)
@@ -61,27 +61,10 @@ public:
   iterator end() const { return Context->getTranslationUnitDecl()->decls_end(); }
 };
   
-/// EmitASTBitcodeFile - Emit a translation unit to a bitcode file.
-bool EmitASTBitcodeFile(const TranslationUnit& TU, 
-                        const llvm::sys::Path& Filename);
-  
-bool EmitASTBitcodeFile(const TranslationUnit* TU, 
-                        const llvm::sys::Path& Filename);
-                     
-/// EmitASTBitcodeStream - Emit a translation unit to a std::ostream.
-bool EmitASTBitcodeStream(const TranslationUnit& TU, 
-                          std::ostream& Stream);
-  
-bool EmitASTBitcodeStream(const TranslationUnit* TU, 
-                          std::ostream& Stream);
-                     
 /// EmitASTBitcodeBuffer - Emit a translation unit to a buffer.
 bool EmitASTBitcodeBuffer(const TranslationUnit& TU, 
                           std::vector<unsigned char>& Buffer);
 
-bool EmitASTBitcodeBuffer(const TranslationUnit* TU, 
-                          std::vector<unsigned char>& Buffer);
-
 /// ReadASTBitcodeBuffer - Reconsitute a translation unit from a buffer.
 TranslationUnit* ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer,
                                       FileManager& FMgr); 
index a0a800c1e31490be68f1a26d12085c3dd8278220..55ab1a736098da1f20fef9dd5caa3367848a3ab2 100644 (file)
@@ -39,24 +39,6 @@ TranslationUnit::~TranslationUnit() {
   }  
 }
 
-bool clang::EmitASTBitcodeFile(const TranslationUnit* TU,                   
-                               const llvm::sys::Path& Filename) {
-
-  return TU ? EmitASTBitcodeFile(*TU, Filename) : false;
-}
-  
-bool clang::EmitASTBitcodeBuffer(const TranslationUnit* TU, 
-                                 std::vector<unsigned char>& Buffer) {
-
-  return TU ? EmitASTBitcodeBuffer(*TU, Buffer) : false;
-}
-
-bool clang::EmitASTBitcodeStream(const TranslationUnit* TU, 
-                                 std::ostream& Stream) {
-
-  return TU ? EmitASTBitcodeStream(*TU, Stream) : false;
-}
-
 bool clang::EmitASTBitcodeBuffer(const TranslationUnit& TU, 
                                  std::vector<unsigned char>& Buffer) {
   // Create bitstream.
@@ -82,39 +64,6 @@ bool clang::EmitASTBitcodeBuffer(const TranslationUnit& TU,
   return true;
 }
 
-bool clang::EmitASTBitcodeStream(const TranslationUnit& TU, 
-                                 std::ostream& Stream) {  
-  
-  // Reserve 256K for bitstream buffer.
-  std::vector<unsigned char> Buffer;
-  Buffer.reserve(256*1024);
-  
-  EmitASTBitcodeBuffer(TU,Buffer);
-  
-  // Write the bits to disk.
-  Stream.write((char*)&Buffer.front(), Buffer.size());
-  return true;
-}
-
-bool clang::EmitASTBitcodeFile(const TranslationUnit& TU, 
-                               const llvm::sys::Path& Filename) {  
-  
-  // Reserve 256K for bitstream buffer.
-  std::vector<unsigned char> Buffer;
-  Buffer.reserve(256*1024);
-  
-  EmitASTBitcodeBuffer(TU,Buffer);
-  
-  // Write the bits to disk. 
-  if (FILE* fp = fopen(Filename.c_str(),"wb")) {
-    fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
-    fclose(fp);
-    return true;
-  }
-
-  return false;  
-}
-
 TranslationUnit*
 clang::ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer, FileManager& FMgr) {
 
index c3828a9e2bb9fa56c8dfb69d2d502a9be6fa5efb..c040a54b44bfc458857dd5a6382ad3896a0a6dc2 100644 (file)
@@ -977,7 +977,18 @@ public:
   virtual void HandleTranslationUnit(TranslationUnit& TU) {
     if (Diags.hasErrorOccurred())
       return;
-    EmitASTBitcodeFile(&TU, FName);
+    
+    // Reserve 256K for bitstream buffer.
+    std::vector<unsigned char> Buffer;
+    Buffer.reserve(256*1024);
+    
+    EmitASTBitcodeBuffer(TU,Buffer);
+    
+    // Write the bits to disk. 
+    if (FILE* fp = fopen(FName.c_str(),"wb")) {
+      fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
+      fclose(fp);
+    }
   }
 };
 
@@ -1016,7 +1027,19 @@ public:
     sprintf(&buf[0], "%s-%llX.ast", FE->getName(),
             (unsigned long long) FE->getInode());
     FName.appendComponent(&buf[0]);    
-    EmitASTBitcodeFile(&TU, FName);
+    
+    
+    // Reserve 256K for bitstream buffer.
+    std::vector<unsigned char> Buffer;
+    Buffer.reserve(256*1024);
+    
+    EmitASTBitcodeBuffer(TU,Buffer);
+    
+    // Write the bits to disk. 
+    if (FILE* fp = fopen(FName.c_str(),"wb")) {
+      fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
+      fclose(fp);
+    }
     
     // Now emit the sources.
     
index fcc047e0156bea3b0854ea87dfcc2a0c44b987df..aa3163f5566068ad53dfe336f673e384e80dfb3e 100644 (file)
@@ -74,7 +74,21 @@ bool SerializationTest::Serialize(llvm::sys::Path& Filename,
   }
   
   // Serialize the translation unit.
-  return EmitASTBitcodeFile(TU,Filename);
+  
+  // Reserve 256K for bitstream buffer.
+  std::vector<unsigned char> Buffer;
+  Buffer.reserve(256*1024);
+  
+  EmitASTBitcodeBuffer(TU,Buffer);
+  
+  // Write the bits to disk. 
+  if (FILE* fp = fopen(Filename.c_str(),"wb")) {
+    fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
+    fclose(fp);
+    return true;
+  }
+  
+  return false;
 }
 
 bool SerializationTest::Deserialize(llvm::sys::Path& Filename,