From: Daniel Dunbar Date: Wed, 22 Oct 2008 17:40:45 +0000 (+0000) Subject: [LLVM up] Get rid of std::ostream usage from Backend.cpp X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed2cb285522513d33b001900acf211cc5ee2175b;p=clang [LLVM up] Get rid of std::ostream usage from Backend.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57990 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/Backend.cpp b/Driver/Backend.cpp index 9f36b2a1a1..2121749f3d 100644 --- a/Driver/Backend.cpp +++ b/Driver/Backend.cpp @@ -24,7 +24,6 @@ #include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/ScheduleDAG.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Streams.h" #include "llvm/Support/Compiler.h" #include "llvm/System/Path.h" #include "llvm/System/Program.h" @@ -46,7 +45,6 @@ namespace { llvm::Module *TheModule; llvm::TargetData *TheTargetData; llvm::raw_ostream *AsmOutStream; - std::ostream *AsmStdOutStream; mutable FunctionPassManager *CodeGenPasses; mutable PassManager *PerModulePasses; @@ -79,16 +77,13 @@ namespace { InputFile(infile), OutputFile(outfile), Gen(CreateLLVMCodeGen(Diags, Features, InputFile, GenerateDebugInfo)), - TheModule(0), TheTargetData(0), - AsmOutStream(0), AsmStdOutStream(0), + TheModule(0), TheTargetData(0), AsmOutStream(0), CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {} ~BackendConsumer() { // FIXME: Move out of destructor. EmitAssembly(); - if (AsmStdOutStream != llvm::cout.stream()) - delete AsmStdOutStream; delete AsmOutStream; delete TheTargetData; delete TheModule; @@ -166,11 +161,7 @@ bool BackendConsumer::AddEmitPasses(bool Fast, std::string &Error) { RegisterRegAlloc::setDefault(Fast ? createLocalRegisterAllocator : createLinearScanRegisterAllocator); - // This is ridiculous. - // FIXME: These aren't being release for now. I'm just going to fix - // things to use raw_ostream instead. if (OutputFile == "-" || (InputFile == "-" && OutputFile.empty())) { - AsmStdOutStream = llvm::cout.stream(); AsmOutStream = new raw_stdout_ostream(); sys::Program::ChangeStdoutToBinary(); } else { @@ -187,19 +178,14 @@ bool BackendConsumer::AddEmitPasses(bool Fast, std::string &Error) { OutputFile = Path.toString(); } - // FIXME: raw_fd_ostream should specify its non-error condition - // better. - Error = ""; - AsmStdOutStream = new std::ofstream(OutputFile.c_str(), - (std::ios_base::binary | - std::ios_base::out)); - AsmOutStream = new raw_os_ostream(*AsmStdOutStream); + // FIXME: Should be binary. + AsmOutStream = new raw_fd_ostream(OutputFile.c_str(), Error); if (!Error.empty()) return false; } if (Action == Backend_EmitBC) { - getPerModulePasses()->add(CreateBitcodeWriterPass(*AsmStdOutStream)); + getPerModulePasses()->add(createBitcodeWriterPass(*AsmOutStream)); } else if (Action == Backend_EmitLL) { getPerModulePasses()->add(createPrintModulePass(AsmOutStream)); } else {