Removed #include <iostream> and replace with llvm_* streams.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31927 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2006-11-26 10:52:51 +00:00
parent 7fe9518698
commit fe6b146dcd
6 changed files with 57 additions and 56 deletions

View File

@ -13,7 +13,7 @@
#include "llvm/Support/Allocator.h"
#include "llvm/Support/DataTypes.h"
#include <iostream>
#include "llvm/Support/Streams.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@ -102,6 +102,6 @@ void BumpPtrAllocator::PrintStats() const {
for (; R; R = R->getNext(), ++NumRegions)
BytesUsed += R->getNumBytesAllocated();
std::cerr << "\nNumber of memory regions: " << NumRegions << "\n";
std::cerr << "Bytes allocated: " << BytesUsed << "\n";
llvm_cerr << "\nNumber of memory regions: " << NumRegions << "\n";
llvm_cerr << "Bytes allocated: " << BytesUsed << "\n";
}

View File

@ -19,12 +19,12 @@
#include "llvm/Config/config.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/Path.h"
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <iostream>
#include <cstdlib>
#include <cerrno>
#include <cstring>
@ -84,7 +84,7 @@ static Option *getOption(const std::string &Str) {
static void AddArgument(const char *ArgName, Option *Opt) {
if (getOption(ArgName)) {
std::cerr << ProgramName << ": CommandLine Error: Argument '"
llvm_cerr << ProgramName << ": CommandLine Error: Argument '"
<< ArgName << "' defined more than once!\n";
} else {
// Add argument to the argument map!
@ -129,7 +129,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
case ValueOptional:
break;
default:
std::cerr << ProgramName
llvm_cerr << ProgramName
<< ": Bad ValueMask flag! CommandLine usage error:"
<< Handler->getValueExpectedFlag() << "\n";
abort();
@ -468,8 +468,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
}
if (Handler == 0) {
std::cerr << ProgramName << ": Unknown command line argument '"
<< argv[i] << "'. Try: '" << argv[0] << " --help'\n";
llvm_cerr << ProgramName << ": Unknown command line argument '"
<< argv[i] << "'. Try: '" << argv[0] << " --help'\n";
ErrorParsing = true;
continue;
}
@ -505,7 +505,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
// Check and handle positional arguments now...
if (NumPositionalRequired > PositionalVals.size()) {
std::cerr << ProgramName
llvm_cerr << ProgramName
<< ": Not enough positional command line arguments specified!\n"
<< "Must specify at least " << NumPositionalRequired
<< " positional arguments: See: " << argv[0] << " --help\n";
@ -513,7 +513,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
ErrorParsing = true;
} else if (!HasUnlimitedPositionals
&& PositionalVals.size() > PositionalOpts.size()) {
std::cerr << ProgramName
llvm_cerr << ProgramName
<< ": Too many positional arguments specified!\n"
<< "Can specify at most " << PositionalOpts.size()
<< " positional arguments: See: " << argv[0] << " --help\n";
@ -617,11 +617,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
bool Option::error(std::string Message, const char *ArgName) {
if (ArgName == 0) ArgName = ArgStr;
if (ArgName[0] == 0)
std::cerr << HelpStr; // Be nice for positional arguments
llvm_cerr << HelpStr; // Be nice for positional arguments
else
std::cerr << ProgramName << ": for the -" << ArgName;
llvm_cerr << ProgramName << ": for the -" << ArgName;
std::cerr << " option: " << Message << "\n";
llvm_cerr << " option: " << Message << "\n";
return true;
}
@ -701,7 +701,7 @@ unsigned alias::getOptionWidth() const {
// Print out the option for the alias.
void alias::printOptionInfo(unsigned GlobalWidth) const {
unsigned L = std::strlen(ArgStr);
std::cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
llvm_cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
<< HelpStr << "\n";
}
@ -728,12 +728,12 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const {
//
void basic_parser_impl::printOptionInfo(const Option &O,
unsigned GlobalWidth) const {
std::cout << " -" << O.ArgStr;
llvm_cout << " -" << O.ArgStr;
if (const char *ValName = getValueName())
std::cout << "=<" << getValueStr(O, ValName) << ">";
llvm_cout << "=<" << getValueStr(O, ValName) << ">";
std::cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - "
llvm_cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - "
<< O.HelpStr << "\n";
}
@ -850,20 +850,20 @@ void generic_parser_base::printOptionInfo(const Option &O,
unsigned GlobalWidth) const {
if (O.hasArgStr()) {
unsigned L = std::strlen(O.ArgStr);
std::cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ')
llvm_cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ')
<< " - " << O.HelpStr << "\n";
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8;
std::cout << " =" << getOption(i) << std::string(NumSpaces, ' ')
llvm_cout << " =" << getOption(i) << std::string(NumSpaces, ' ')
<< " - " << getDescription(i) << "\n";
}
} else {
if (O.HelpStr[0])
std::cout << " " << O.HelpStr << "\n";
llvm_cout << " " << O.HelpStr << "\n";
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned L = std::strlen(getOption(i));
std::cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ')
llvm_cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ')
<< " - " << getDescription(i) << "\n";
}
}
@ -917,9 +917,9 @@ public:
}
if (ProgramOverview)
std::cout << "OVERVIEW:" << ProgramOverview << "\n";
llvm_cout << "OVERVIEW:" << ProgramOverview << "\n";
std::cout << "USAGE: " << ProgramName << " [options]";
llvm_cout << "USAGE: " << ProgramName << " [options]";
// Print out the positional options.
std::vector<Option*> &PosOpts = *PositionalOptions;
@ -929,28 +929,28 @@ public:
for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) {
if (PosOpts[i]->ArgStr[0])
std::cout << " --" << PosOpts[i]->ArgStr;
std::cout << " " << PosOpts[i]->HelpStr;
llvm_cout << " --" << PosOpts[i]->ArgStr;
llvm_cout << " " << PosOpts[i]->HelpStr;
}
// Print the consume after option info if it exists...
if (CAOpt) std::cout << " " << CAOpt->HelpStr;
if (CAOpt) llvm_cout << " " << CAOpt->HelpStr;
std::cout << "\n\n";
llvm_cout << "\n\n";
// Compute the maximum argument length...
MaxArgLen = 0;
for (unsigned i = 0, e = Opts.size(); i != e; ++i)
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
std::cout << "OPTIONS:\n";
llvm_cout << "OPTIONS:\n";
for (unsigned i = 0, e = Opts.size(); i != e; ++i)
Opts[i].second->printOptionInfo(MaxArgLen);
// Print any extra help the user has declared.
for (std::vector<const char *>::iterator I = MoreHelp->begin(),
E = MoreHelp->end(); I != E; ++I)
std::cout << *I;
llvm_cout << *I;
MoreHelp->clear();
// Halt the program since help information was printed
@ -982,21 +982,21 @@ public:
void operator=(bool OptionWasSpecified) {
if (OptionWasSpecified) {
if (OverrideVersionPrinter == 0) {
std::cout << "Low Level Virtual Machine (http://llvm.org/):\n";
std::cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
llvm_cout << "Low Level Virtual Machine (http://llvm.org/):\n";
llvm_cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
#ifdef LLVM_VERSION_INFO
std::cout << LLVM_VERSION_INFO;
llvm_cout << LLVM_VERSION_INFO;
#endif
std::cout << "\n ";
llvm_cout << "\n ";
#ifndef __OPTIMIZE__
std::cout << "DEBUG build";
llvm_cout << "DEBUG build";
#else
std::cout << "Optimized build";
llvm_cout << "Optimized build";
#endif
#ifndef NDEBUG
std::cout << " with assertions";
llvm_cout << " with assertions";
#endif
std::cout << ".\n";
llvm_cout << ".\n";
Options->clear(); // Don't bother making option dtors remove from map.
exit(1);
} else {

View File

@ -12,10 +12,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/Path.h"
#include "llvm/System/Program.h"
#include "llvm/Config/config.h"
#include <iostream>
using namespace llvm;
void llvm::DisplayGraph(const sys::Path &Filename) {
@ -28,9 +28,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
args.push_back(Filename.c_str());
args.push_back(0);
std::cerr << "Running 'Graphviz' program... " << std::flush;
llvm_cerr << "Running 'Graphviz' program... " << std::flush;
if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,&ErrMsg)) {
std::cerr << "Error viewing graph: " << ErrMsg << "\n";
llvm_cerr << "Error viewing graph: " << ErrMsg << "\n";
}
#elif (HAVE_GV && HAVE_DOT)
sys::Path PSFilename = Filename;
@ -48,11 +48,11 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
args.push_back(PSFilename.c_str());
args.push_back(0);
std::cerr << "Running 'dot' program... " << std::flush;
llvm_cerr << "Running 'dot' program... " << std::flush;
if (sys::Program::ExecuteAndWait(dot, &args[0],0,0,0,&ErrMsg)) {
std::cerr << "Error viewing graph: '" << ErrMsg << "\n";
llvm_cerr << "Error viewing graph: '" << ErrMsg << "\n";
} else {
std::cerr << " done. \n";
llvm_cerr << " done. \n";
sys::Path gv(LLVM_PATH_GV);
args.clear();
@ -62,7 +62,7 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
ErrMsg.clear();
if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,&ErrMsg)) {
std::cerr << "Error viewing graph: " << ErrMsg << "\n";
llvm_cerr << "Error viewing graph: " << ErrMsg << "\n";
}
}
PSFilename.eraseFromDisk();
@ -73,9 +73,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) {
args.push_back(Filename.c_str());
args.push_back(0);
std::cerr << "Running 'dotty' program... " << std::flush;
llvm_cerr << "Running 'dotty' program... " << std::flush;
if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,&ErrMsg)) {
std::cerr << "Error viewing graph: " << ErrMsg << "\n";
llvm_cerr << "Error viewing graph: " << ErrMsg << "\n";
} else {
#ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns
return;

View File

@ -13,8 +13,8 @@
#define DONT_GET_PLUGIN_LOADER_OPTION
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h"
#include <iostream>
#include <vector>
using namespace llvm;
@ -26,7 +26,7 @@ void PluginLoader::operator=(const std::string &Filename) {
std::string Error;
if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
std::cerr << "Error opening '" << Filename << "': " << Error
llvm_cerr << "Error opening '" << Filename << "': " << Error
<< "\n -load request ignored.\n";
} else {
Plugins->push_back(Filename);

View File

@ -12,8 +12,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/SlowOperationInformer.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/Alarm.h"
#include <iostream>
#include <sstream>
#include <cassert>
using namespace llvm;
@ -28,7 +28,7 @@ SlowOperationInformer::~SlowOperationInformer() {
if (LastPrintAmount) {
// If we have printed something, make _sure_ we print the 100% amount, and
// also print a newline.
std::cout << std::string(LastPrintAmount, '\b') << "Progress "
llvm_cout << std::string(LastPrintAmount, '\b') << "Progress "
<< OperationName << ": 100% \n";
}
}
@ -40,7 +40,7 @@ SlowOperationInformer::~SlowOperationInformer() {
bool SlowOperationInformer::progress(unsigned Amount) {
int status = sys::AlarmStatus();
if (status == -1) {
std::cout << "\n";
llvm_cout << "\n";
LastPrintAmount = 0;
return true;
}
@ -61,6 +61,6 @@ bool SlowOperationInformer::progress(unsigned Amount) {
OS << "% ";
LastPrintAmount = OS.str().size();
std::cout << ToPrint+OS.str() << std::flush;
llvm_cout << ToPrint+OS.str() << std::flush;
return false;
}

View File

@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/Streams.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/System/Process.h"
#include "llvm/System/Program.h"
@ -22,10 +23,10 @@ bool llvm::CheckBytecodeOutputToConsole(std::ostream* stream_to_check,
bool print_warning) {
if (stream_to_check == &std::cout && sys::Process::StandardOutIsDisplayed()) {
if (print_warning) {
std::cerr << "WARNING: You're attempting to print out a bytecode file.\n"
"This is inadvisable as it may cause display problems. If\n"
"you REALLY want to taste LLVM bytecode first-hand, you\n"
"can force output with the `-f' option.\n\n";
llvm_cerr << "WARNING: You're attempting to print out a bytecode file.\n"
<< "This is inadvisable as it may cause display problems. If\n"
<< "you REALLY want to taste LLVM bytecode first-hand, you\n"
<< "can force output with the `-f' option.\n\n";
}
return true;
}