llvm.org GIT mirror llvm / d928fb6
Don't special-case stdout in llvm::WriteBitcodeToFile; just consider it to be the caller's responsibility to provide a stream in binary mode. This fixes a layering violation and avoids an outs() call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104878 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
3 changed file(s) with 8 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
3939 std::string *ErrMsg = 0);
4040
4141 /// WriteBitcodeToFile - Write the specified module to the specified
42 /// raw output stream.
42 /// raw output stream. For streams where it matters, the given stream
43 /// should be in "binary" mode.
4344 void WriteBitcodeToFile(const Module *M, raw_ostream &Out);
4445
4546 /// WriteBitcodeToStream - Write the specified module to the specified
16611661
16621662 WriteBitcodeToStream( M, Stream );
16631663
1664 // If writing to stdout, set binary mode.
1665 if (&llvm::outs() == &Out)
1666 sys::Program::ChangeStdoutToBinary();
1667
16681664 // Write the generated bitstream to "Out".
16691665 Out.write((char*)&Buffer.front(), Buffer.size());
16701666
376376 }
377377
378378 // Figure out what stream we are supposed to write to...
379 // FIXME: outs() is not binary!
380379 raw_ostream *Out = 0;
381380 bool DeleteStream = false;
382381 if (!NoOutput && !AnalyzeOnly) {
383382 if (OutputFilename == "-") {
384 Out = &outs(); // Default to printing to stdout...
383 // Print to stdout.
384 Out = &outs();
385 // If we're printing a bitcode file, switch stdout to binary mode.
386 // FIXME: This switches outs() globally, not just for the bitcode output.
387 if (!OutputAssembly)
388 sys::Program::ChangeStdoutToBinary();
385389 } else {
386390 if (NoOutput || AnalyzeOnly) {
387391 errs() << "WARNING: The -o (output filename) option is ignored when\n"