llvm.org GIT mirror llvm / fdc8f78
Bitcode: Don't expose WriteBitcodeToStream to clients. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151747 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 7 years ago
3 changed file(s) with 8 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
6161 /// raw output stream. For streams where it matters, the given stream
6262 /// should be in "binary" mode.
6363 void WriteBitcodeToFile(const Module *M, raw_ostream &Out);
64
65 /// WriteBitcodeToStream - Write the specified module to the specified
66 /// raw output stream.
67 void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream);
6864
6965 /// createBitcodeWriterPass - Create and return a pass that writes the module
7066 /// to the specified ostream.
18221822 }
18231823 }
18241824
1825 static void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream);
18251826
18261827 /// WriteBitcodeToFile - Write the specified module to the specified output
18271828 /// stream.
18371838 Out.write((char*)&Buffer.front(), Buffer.size());
18381839 }
18391840
1840 /// WriteBitcodeToStream - Write the specified module to the specified output
1841 /// stream.
1842 void llvm::WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream) {
1841 static void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream) {
18431842 // If this is darwin or another generic macho target, emit a file header and
18441843 // trailer if needed.
18451844 Triple TT(M->getTargetTriple());
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/ADT/SmallString.h"
910 #include "llvm/Analysis/Verifier.h"
1011 #include "llvm/Bitcode/BitstreamWriter.h"
1112 #include "llvm/Bitcode/ReaderWriter.h"
4243 return Mod;
4344 }
4445
45 static void writeModuleToBuffer(std::vectorchar> &Buffer) {
46 static void writeModuleToBuffer(SmallVectorImpl<char> &Buffer) {
4647 Module *Mod = makeLLVMModule();
47 BitstreamWriter Stream(Buffer);
48 WriteBitcodeToStream(Mod, Stream);
48 raw_svector_ostream OS(Buffer);
49 WriteBitcodeToFile(Mod, OS);
4950 }
5051
5152 TEST(BitReaderTest, MaterializeFunctionsForBlockAddr) { // PR11677
52 std::vector> Mem;
53 SmallString<1024> Mem;
5354 writeModuleToBuffer(Mem);
54 StringRef Data((const char*)&Mem[0], Mem.size());
55 MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Data, "test", false);
55 MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
5656 std::string errMsg;
5757 Module *m = getLazyBitcodeModule(Buffer, getGlobalContext(), &errMsg);
5858 PassManager passes;