Fix build failure.
Patch by Erick Tryzelaar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57355 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/lto-bugpoint/LTOBugPoint.cpp b/tools/lto-bugpoint/LTOBugPoint.cpp
index 587e360..96acf4a 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 <fstream>
@@ -189,7 +190,13 @@
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)) {