Changes to build successfully with GCC 3.02

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1503 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-01-20 22:54:45 +00:00
parent 13c4659220
commit 697954c15d
230 changed files with 2373 additions and 2445 deletions

View File

@@ -24,6 +24,8 @@
#include "Support/PostOrderIterator.h"
#include "Support/CommandLine.h"
#include <fstream>
#include <iostream>
using std::cerr;
// OutputMode - The different orderings to print basic blocks in...
enum OutputMode {
@@ -47,7 +49,7 @@ cl::EnumFlags<enum OutputMode> WriteMode(cl::NoFlags,
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
ostream *Out = &cout; // Default to printing to stdout...
std::ostream *Out = &std::cout; // Default to printing to stdout...
Module *C = ParseBytecodeFile(InputFilename);
if (C == 0) {
@@ -56,31 +58,41 @@ int main(int argc, char **argv) {
}
if (OutputFilename != "") { // Specified an output filename?
Out = new ofstream(OutputFilename.c_str(),
(Force ? 0 : ios::noreplace)|ios::out);
if (!Force && !std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
cerr << "Error opening '" << OutputFilename
<< "': File exists! Sending to standard output.\n";
} else {
Out = new std::ofstream(OutputFilename.c_str());
}
} else {
if (InputFilename == "-") {
OutputFilename = "-";
Out = &cout;
} else {
string IFN = InputFilename;
std::string IFN = InputFilename;
int Len = IFN.length();
if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
// Source ends in .bc
OutputFilename = string(IFN.begin(), IFN.end()-3);
OutputFilename = std::string(IFN.begin(), IFN.end()-3);
} else {
OutputFilename = IFN; // Append a .ll to it
}
OutputFilename += ".ll";
Out = new ofstream(OutputFilename.c_str(),
(Force ? 0 : ios::noreplace)|ios::out);
if (!Force && !std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
cerr << "Error opening '" << OutputFilename
<< "': File exists! Sending to standard output.\n";
} else {
Out = new std::ofstream(OutputFilename.c_str());
}
}
}
if (!Out->good()) {
cerr << "Error opening " << OutputFilename
<< ": sending to stdout instead!\n";
Out = &cout;
Out = &std::cout;
}
// All that dis does is write the assembly out to a file... which is exactly
@@ -100,20 +112,20 @@ int main(int argc, char **argv) {
switch (WriteMode) {
case dfo: // Depth First ordering
copy(df_begin(M), df_end(M),
ostream_iterator<BasicBlock*>(*Out, "\n"));
std::ostream_iterator<BasicBlock*>(*Out, "\n"));
break;
case rdfo: // Reverse Depth First ordering
copy(df_begin(M, true), df_end(M),
ostream_iterator<BasicBlock*>(*Out, "\n"));
std::ostream_iterator<BasicBlock*>(*Out, "\n"));
break;
case po: // Post Order
copy(po_begin(M), po_end(M),
ostream_iterator<BasicBlock*>(*Out, "\n"));
std::ostream_iterator<BasicBlock*>(*Out, "\n"));
break;
case rpo: { // Reverse Post Order
ReversePostOrderTraversal RPOT(M);
copy(RPOT.begin(), RPOT.end(),
ostream_iterator<BasicBlock*>(*Out, "\n"));
std::ostream_iterator<BasicBlock*>(*Out, "\n"));
break;
}
default:
@@ -124,6 +136,6 @@ int main(int argc, char **argv) {
}
delete C;
if (Out != &cout) delete Out;
if (Out != &std::cout) delete Out;
return 0;
}