aboutsummaryrefslogtreecommitdiff
path: root/tools/lto/LTOCodeGenerator.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-21 00:14:44 +0000
committerOwen Anderson <resistor@mac.com>2008-08-21 00:14:44 +0000
commitcb3718832375a581c5ea23f15918f3ea447a446c (patch)
treea72c740cc8590cd63825fcf08f71c5e2f625ca55 /tools/lto/LTOCodeGenerator.cpp
parentf4a97da4072a2ee4aca3c668a9fa113c06fdef8d (diff)
Use raw_ostream throughout the AsmPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto/LTOCodeGenerator.cpp')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index ad3964d3f7..275aac208f 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -27,6 +27,7 @@
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/LoopPass.h"
@@ -162,9 +163,12 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg)
sys::RemoveFileOnSignal(uniqueAsmPath);
// generate assembly code
- std::ofstream asmFile(uniqueAsmPath.c_str());
- bool genResult = this->generateAssemblyCode(asmFile, errMsg);
- asmFile.close();
+ std::string error;
+ bool genResult = false;
+ {
+ raw_fd_ostream asmFile(uniqueAsmPath.c_str(), error);
+ genResult = this->generateAssemblyCode(asmFile, errMsg);
+ }
if ( genResult ) {
if ( uniqueAsmPath.exists() )
uniqueAsmPath.eraseFromDisk();
@@ -309,7 +313,8 @@ void LTOCodeGenerator::applyScopeRestrictions()
}
/// Optimize merged modules using various IPO passes
-bool LTOCodeGenerator::generateAssemblyCode(std::ostream& out, std::string& errMsg)
+bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
+ std::string& errMsg)
{
if ( this->determineTarget(errMsg) )
return true;