Remove uses of Streams.h from CommandLine.cpp, fix some whitespace and other minor tweaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2009-08-23 10:01:13 +00:00
parent 6f5cc82686
commit d227a3fb1a

View File

@@ -22,7 +22,6 @@
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/System/Path.h" #include "llvm/System/Path.h"
#include <algorithm> #include <algorithm>
@@ -124,7 +123,7 @@ static void GetOptionInfo(std::vector<Option*> &PositionalOpts,
// Add argument to the argument map! // Add argument to the argument map!
if (!OptionsMap.insert(std::pair<std::string,Option*>(OptionNames[i], if (!OptionsMap.insert(std::pair<std::string,Option*>(OptionNames[i],
O)).second) { O)).second) {
cerr << ProgramName << ": CommandLine Error: Argument '" errs() << ProgramName << ": CommandLine Error: Argument '"
<< OptionNames[i] << "' defined more than once!\n"; << OptionNames[i] << "' defined more than once!\n";
} }
} }
@@ -203,7 +202,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
case ValueOptional: case ValueOptional:
break; break;
default: default:
cerr << ProgramName errs() << ProgramName
<< ": Bad ValueMask flag! CommandLine usage error:" << ": Bad ValueMask flag! CommandLine usage error:"
<< Handler->getValueExpectedFlag() << "\n"; << Handler->getValueExpectedFlag() << "\n";
llvm_unreachable(0); llvm_unreachable(0);
@@ -609,7 +608,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
if (Handler == 0) { if (Handler == 0) {
if (SinkOpts.empty()) { if (SinkOpts.empty()) {
cerr << ProgramName << ": Unknown command line argument '" errs() << ProgramName << ": Unknown command line argument '"
<< argv[i] << "'. Try: '" << argv[0] << " --help'\n"; << argv[i] << "'. Try: '" << argv[0] << " --help'\n";
ErrorParsing = true; ErrorParsing = true;
} else { } else {
@@ -651,7 +650,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
// Check and handle positional arguments now... // Check and handle positional arguments now...
if (NumPositionalRequired > PositionalVals.size()) { if (NumPositionalRequired > PositionalVals.size()) {
cerr << ProgramName errs() << ProgramName
<< ": Not enough positional command line arguments specified!\n" << ": Not enough positional command line arguments specified!\n"
<< "Must specify at least " << NumPositionalRequired << "Must specify at least " << NumPositionalRequired
<< " positional arguments: See: " << argv[0] << " --help\n"; << " positional arguments: See: " << argv[0] << " --help\n";
@@ -659,7 +658,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
ErrorParsing = true; ErrorParsing = true;
} else if (!HasUnlimitedPositionals } else if (!HasUnlimitedPositionals
&& PositionalVals.size() > PositionalOpts.size()) { && PositionalVals.size() > PositionalOpts.size()) {
cerr << ProgramName errs() << ProgramName
<< ": Too many positional arguments specified!\n" << ": Too many positional arguments specified!\n"
<< "Can specify at most " << PositionalOpts.size() << "Can specify at most " << PositionalOpts.size()
<< " positional arguments: See: " << argv[0] << " --help\n"; << " positional arguments: See: " << argv[0] << " --help\n";
@@ -771,11 +770,11 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
bool Option::error(std::string Message, const char *ArgName) { bool Option::error(std::string Message, const char *ArgName) {
if (ArgName == 0) ArgName = ArgStr; if (ArgName == 0) ArgName = ArgStr;
if (ArgName[0] == 0) if (ArgName[0] == 0)
cerr << HelpStr; // Be nice for positional arguments errs() << HelpStr; // Be nice for positional arguments
else else
cerr << ProgramName << ": for the -" << ArgName; errs() << ProgramName << ": for the -" << ArgName;
cerr << " option: " << Message << "\n"; errs() << " option: " << Message << "\n";
return true; return true;
} }
@@ -824,7 +823,7 @@ size_t alias::getOptionWidth() const {
// Print out the option for the alias. // Print out the option for the alias.
void alias::printOptionInfo(size_t GlobalWidth) const { void alias::printOptionInfo(size_t GlobalWidth) const {
size_t L = std::strlen(ArgStr); size_t L = std::strlen(ArgStr);
cerr << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " errs() << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
<< HelpStr << "\n"; << HelpStr << "\n";
} }
@@ -1124,43 +1123,41 @@ namespace {
class VersionPrinter { class VersionPrinter {
public: public:
void print() { void print() {
raw_ostream &stdout = outs(); outs() << "Low Level Virtual Machine (http://llvm.org/):\n"
stdout << "Low Level Virtual Machine (http://llvm.org/):\n"; << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
stdout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
#ifdef LLVM_VERSION_INFO #ifdef LLVM_VERSION_INFO
stdout << LLVM_VERSION_INFO; outs() << LLVM_VERSION_INFO;
#endif #endif
stdout << "\n "; outs() << "\n ";
#ifndef __OPTIMIZE__ #ifndef __OPTIMIZE__
stdout << "DEBUG build"; outs() << "DEBUG build";
#else #else
stdout << "Optimized build"; outs() << "Optimized build";
#endif #endif
#ifndef NDEBUG #ifndef NDEBUG
stdout << " with assertions"; outs() << " with assertions";
#endif #endif
stdout << ".\n"; outs() << ".\n"
stdout << " Built " << __DATE__ << "(" << __TIME__ << ").\n"; << " Built " << __DATE__ << " (" << __TIME__ << ").\n"
stdout << "\n"; << "\n"
stdout << " Registered Targets:\n"; << " Registered Targets:\n";
std::vector<std::pair<std::string, const Target*> > Targets; std::vector<std::pair<std::string, const Target*> > Targets;
size_t Width = 0; size_t Width = 0;
for (TargetRegistry::iterator it = TargetRegistry::begin(), for (TargetRegistry::iterator it = TargetRegistry::begin(),
ie = TargetRegistry::end(); it != ie; ++it) { ie = TargetRegistry::end(); it != ie; ++it) {
Targets.push_back(std::make_pair(it->getName(), &*it)); Targets.push_back(std::make_pair(it->getName(), &*it));
Width = std::max(Width, ::strlen(it->getName())); Width = std::max(Width, Targets.back().first.length());
} }
std::sort(Targets.begin(), Targets.end()); std::sort(Targets.begin(), Targets.end());
for (unsigned i = 0, e = Targets.size(); i != e; ++i) { for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
const Target *T = Targets[i].second; outs() << " " << Targets[i].first
stdout << " " << T->getName() << std::string(Width - Targets[i].first.length(), ' ') << " - "
<< std::string(Width - ::strlen(T->getName()), ' ') << " - " << Targets[i].second->getShortDescription() << "\n";
<< T->getShortDescription() << "\n"; }
} if (Targets.empty())
if (Targets.empty()) outs() << " (none)\n";
stdout << " (none)\n";
} }
void operator=(bool OptionWasSpecified) { void operator=(bool OptionWasSpecified) {
if (OptionWasSpecified) { if (OptionWasSpecified) {