[cfe-commits] r67904 - in /cfe/trunk: include/clang/AST/TranslationUnit.h lib/AST/TranslationUnit.cpp tools/clang-cc/ASTConsumers.cpp tools/clang-cc/SerializationTest.cpp

Chris Lattner sabre at nondot.org
Fri Mar 27 20:53:03 PDT 2009


Author: lattner
Date: Fri Mar 27 22:53:02 2009
New Revision: 67904

URL: http://llvm.org/viewvc/llvm-project?rev=67904&view=rev
Log:
eliminate some wrappers.

Modified:
    cfe/trunk/include/clang/AST/TranslationUnit.h
    cfe/trunk/lib/AST/TranslationUnit.cpp
    cfe/trunk/tools/clang-cc/ASTConsumers.cpp
    cfe/trunk/tools/clang-cc/SerializationTest.cpp

Modified: cfe/trunk/include/clang/AST/TranslationUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TranslationUnit.h?rev=67904&r1=67903&r2=67904&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/TranslationUnit.h (original)
+++ cfe/trunk/include/clang/AST/TranslationUnit.h Fri Mar 27 22:53:02 2009
@@ -61,27 +61,10 @@
   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); 

Modified: cfe/trunk/lib/AST/TranslationUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TranslationUnit.cpp?rev=67904&r1=67903&r2=67904&view=diff

==============================================================================
--- cfe/trunk/lib/AST/TranslationUnit.cpp (original)
+++ cfe/trunk/lib/AST/TranslationUnit.cpp Fri Mar 27 22:53:02 2009
@@ -39,24 +39,6 @@
   }  
 }
 
-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 @@
   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) {
 

Modified: cfe/trunk/tools/clang-cc/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/ASTConsumers.cpp?rev=67904&r1=67903&r2=67904&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/ASTConsumers.cpp (original)
+++ cfe/trunk/tools/clang-cc/ASTConsumers.cpp Fri Mar 27 22:53:02 2009
@@ -977,7 +977,18 @@
   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 @@
     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.
     

Modified: cfe/trunk/tools/clang-cc/SerializationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/SerializationTest.cpp?rev=67904&r1=67903&r2=67904&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/SerializationTest.cpp (original)
+++ cfe/trunk/tools/clang-cc/SerializationTest.cpp Fri Mar 27 22:53:02 2009
@@ -74,7 +74,21 @@
   }
   
   // 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,





More information about the cfe-commits mailing list