mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
CommandLine library cleanup. No longer use getValue/setValue, instead, just treat the commandline
args as the objects they represent and the "right thing" will happen git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -19,8 +19,8 @@
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
cl::String InputFilename ("", "Parse <arg> file, compile to bytecode", 0, "-");
|
||||
cl::String OutputFilename("o", "Override output filename", 0, "");
|
||||
cl::Flag Force ("f", "Overwrite output files", 0, false);
|
||||
cl::String OutputFilename("o", "Override output filename", cl::NoFlags, "");
|
||||
cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false);
|
||||
cl::Flag DumpAsm ("d", "Print assembly as parsed", cl::Hidden, false);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@ -29,38 +29,38 @@ int main(int argc, char **argv) {
|
||||
ostream *Out = 0;
|
||||
try {
|
||||
// Parse the file now...
|
||||
Module *C = ParseAssemblyFile(InputFilename.getValue());
|
||||
Module *C = ParseAssemblyFile(InputFilename);
|
||||
if (C == 0) {
|
||||
cerr << "assembly didn't read correctly.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (DumpAsm.getValue())
|
||||
if (DumpAsm)
|
||||
cerr << "Here's the assembly:\n" << C;
|
||||
|
||||
if (OutputFilename.getValue() != "") { // Specified an output filename?
|
||||
Out = new ofstream(OutputFilename.getValue().c_str(),
|
||||
(Force.getValue() ? 0 : ios::noreplace)|ios::out);
|
||||
if (OutputFilename != "") { // Specified an output filename?
|
||||
Out = new ofstream(OutputFilename.c_str(),
|
||||
(Force ? 0 : ios::noreplace)|ios::out);
|
||||
} else {
|
||||
if (InputFilename.getValue() == "-") {
|
||||
OutputFilename.setValue("-");
|
||||
if (InputFilename == "-") {
|
||||
OutputFilename = "-";
|
||||
Out = &cout;
|
||||
} else {
|
||||
string IFN = InputFilename.getValue();
|
||||
string IFN = InputFilename;
|
||||
int Len = IFN.length();
|
||||
if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
|
||||
// Source ends in .ll
|
||||
OutputFilename.setValue(string(IFN.begin(), IFN.end()-3));
|
||||
OutputFilename = string(IFN.begin(), IFN.end()-3);
|
||||
} else {
|
||||
OutputFilename.setValue(IFN); // Append a .bc to it
|
||||
OutputFilename = IFN; // Append a .bc to it
|
||||
}
|
||||
OutputFilename.setValue(OutputFilename.getValue() + ".bc");
|
||||
Out = new ofstream(OutputFilename.getValue().c_str(),
|
||||
(Force.getValue() ? 0 : ios::noreplace)|ios::out);
|
||||
OutputFilename += ".bc";
|
||||
Out = new ofstream(OutputFilename.c_str(),
|
||||
(Force ? 0 : ios::noreplace)|ios::out);
|
||||
}
|
||||
|
||||
if (!Out->good()) {
|
||||
cerr << "Error opening " << OutputFilename.getValue() << "!\n";
|
||||
cerr << "Error opening " << OutputFilename << "!\n";
|
||||
delete C;
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user