summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/opt.cpp
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2005-01-22 17:36:17 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2005-01-22 17:36:17 +0000
commitc8f1f4bc8e569a71f0067b8825f3bdb77dcd56fd (patch)
tree55b1d008e1cf3c87f4bd6accbe2299dacdb7e907 /llvm/tools/opt/opt.cpp
parente90b0c546976065cb6e09b29081e27e263159fef (diff)
downloadbcm5719-llvm-c8f1f4bc8e569a71f0067b8825f3bdb77dcd56fd.tar.gz
bcm5719-llvm-c8f1f4bc8e569a71f0067b8825f3bdb77dcd56fd.zip
Use binary mode for reading/writing bytecode files
llvm-svn: 19751
Diffstat (limited to 'llvm/tools/opt/opt.cpp')
-rw-r--r--llvm/tools/opt/opt.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index fd339d92d98..f54844cb590 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -95,6 +95,7 @@ int main(int argc, char **argv) {
}
// Figure out what stream we are supposed to write to...
+ // FIXME: cout is not binary!
std::ostream *Out = &std::cout; // Default to printing to stdout...
if (OutputFilename != "-") {
if (!Force && std::ifstream(OutputFilename.c_str())) {
@@ -104,7 +105,9 @@ int main(int argc, char **argv) {
<< "Use -f command line argument to force output\n";
return 1;
}
- Out = new std::ofstream(OutputFilename.c_str());
+ std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
+ std::ios::binary;
+ Out = new std::ofstream(OutputFilename.c_str(), io_mode);
if (!Out->good()) {
std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
@@ -117,8 +120,8 @@ int main(int argc, char **argv) {
}
// If the output is set to be emitted to standard out, and standard out is a
- // console, print out a warning message and refuse to do it. We don't impress
- // anyone by spewing tons of binary goo to a terminal.
+ // console, print out a warning message and refuse to do it. We don't
+ // impress anyone by spewing tons of binary goo to a terminal.
if (!Force && !NoOutput && CheckBytecodeOutputToConsole(Out,!Quiet)) {
NoOutput = true;
}
OpenPOWER on IntegriCloud