From 7a76ed67745a054eaca11daaddb41fc3be90286c Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 10 Oct 2008 17:57:50 +0000 Subject: [PATCH] Fix build failure. Patch by Erick Tryzelaar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57355 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/lto-bugpoint/LTOBugPoint.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/lto-bugpoint/LTOBugPoint.cpp b/tools/lto-bugpoint/LTOBugPoint.cpp index 587e360bc62..96acf4afd06 100644 --- a/tools/lto-bugpoint/LTOBugPoint.cpp +++ b/tools/lto-bugpoint/LTOBugPoint.cpp @@ -24,6 +24,7 @@ #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Support/SystemUtils.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Config/config.h" #include @@ -189,7 +190,13 @@ bool LTOBugPoint::assembleBitcode(llvm::Module *M, const char *AsmFileName) { CGPasses->add(new TargetData(*Target->getTargetData())); MachineCodeEmitter* mce = NULL; - std::ofstream *Out = new std::ofstream(AsmFileName, std::ios::out); + std::string error; + raw_ostream *Out = new raw_fd_ostream(AsmFileName, error); + if (!error.empty()) { + std::cerr << error << '\n'; + delete Out; + return false; + } switch (Target->addPassesToEmitFile(*CGPasses, *Out, TargetMachine::AssemblyFile, true)) {