[llvm-commits] [llvm] r151747 - in /llvm/trunk: include/llvm/Bitcode/ReaderWriter.h lib/Bitcode/Writer/BitcodeWriter.cpp unittests/Bitcode/BitReaderTest.cpp

Daniel Dunbar daniel at zuster.org
Wed Feb 29 12:30:56 PST 2012


Author: ddunbar
Date: Wed Feb 29 14:30:56 2012
New Revision: 151747

URL: http://llvm.org/viewvc/llvm-project?rev=151747&view=rev
Log:
Bitcode: Don't expose WriteBitcodeToStream to clients.

Modified:
    llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/trunk/unittests/Bitcode/BitReaderTest.cpp

Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=151747&r1=151746&r2=151747&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/ReaderWriter.h (original)
+++ llvm/trunk/include/llvm/Bitcode/ReaderWriter.h Wed Feb 29 14:30:56 2012
@@ -63,10 +63,6 @@
   /// should be in "binary" mode.
   void WriteBitcodeToFile(const Module *M, raw_ostream &Out);
 
-  /// WriteBitcodeToStream - Write the specified module to the specified
-  /// raw output stream.
-  void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream);
-
   /// createBitcodeWriterPass - Create and return a pass that writes the module
   /// to the specified ostream.
   ModulePass *createBitcodeWriterPass(raw_ostream &Str);

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=151747&r1=151746&r2=151747&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Wed Feb 29 14:30:56 2012
@@ -1823,6 +1823,7 @@
   }
 }
 
+static void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream);
 
 /// WriteBitcodeToFile - Write the specified module to the specified output
 /// stream.
@@ -1838,9 +1839,7 @@
   Out.write((char*)&Buffer.front(), Buffer.size());
 }
 
-/// WriteBitcodeToStream - Write the specified module to the specified output
-/// stream.
-void llvm::WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream) {
+static void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream) {
   // If this is darwin or another generic macho target, emit a file header and
   // trailer if needed.
   Triple TT(M->getTargetTriple());

Modified: llvm/trunk/unittests/Bitcode/BitReaderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Bitcode/BitReaderTest.cpp?rev=151747&r1=151746&r2=151747&view=diff
==============================================================================
--- llvm/trunk/unittests/Bitcode/BitReaderTest.cpp (original)
+++ llvm/trunk/unittests/Bitcode/BitReaderTest.cpp Wed Feb 29 14:30:56 2012
@@ -7,6 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/Bitcode/BitstreamWriter.h"
 #include "llvm/Bitcode/ReaderWriter.h"
@@ -43,17 +44,16 @@
   return Mod;
 }
 
-static void writeModuleToBuffer(std::vector<unsigned char> &Buffer) {
+static void writeModuleToBuffer(SmallVectorImpl<char> &Buffer) {
   Module *Mod = makeLLVMModule();
-  BitstreamWriter Stream(Buffer);
-  WriteBitcodeToStream(Mod, Stream);
+  raw_svector_ostream OS(Buffer);
+  WriteBitcodeToFile(Mod, OS);
 }
 
 TEST(BitReaderTest, MaterializeFunctionsForBlockAddr) { // PR11677
-  std::vector<unsigned char> Mem;
+  SmallString<1024> Mem;
   writeModuleToBuffer(Mem);
-  StringRef Data((const char*)&Mem[0], Mem.size());
-  MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Data, "test", false);
+  MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
   std::string errMsg;
   Module *m = getLazyBitcodeModule(Buffer, getGlobalContext(), &errMsg);
   PassManager passes;





More information about the llvm-commits mailing list