aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/lto-bugpoint/LTOBugPoint.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/lto-bugpoint/LTOBugPoint.cpp b/tools/lto-bugpoint/LTOBugPoint.cpp
index 587e360bc6..96acf4afd0 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 @@ 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)) {