[llvm-commits] CVS: llvm/lib/Support/Allocator.cpp CommandLine.cpp GraphWriter.cpp PluginLoader.cpp SlowOperationInformer.cpp SystemUtils.cpp
Bill Wendling
isanbard at gmail.com
Sun Nov 26 02:53:06 PST 2006
Changes in directory llvm/lib/Support:
Allocator.cpp updated: 1.2 -> 1.3
CommandLine.cpp updated: 1.78 -> 1.79
GraphWriter.cpp updated: 1.5 -> 1.6
PluginLoader.cpp updated: 1.18 -> 1.19
SlowOperationInformer.cpp updated: 1.10 -> 1.11
SystemUtils.cpp updated: 1.45 -> 1.46
---
Log message:
Removed #include <iostream> and replace with llvm_* streams.
---
Diffs of the changes: (+57 -56)
Allocator.cpp | 6 ++--
CommandLine.cpp | 68 +++++++++++++++++++++++-----------------------
GraphWriter.cpp | 18 ++++++------
PluginLoader.cpp | 4 +-
SlowOperationInformer.cpp | 8 ++---
SystemUtils.cpp | 9 +++---
6 files changed, 57 insertions(+), 56 deletions(-)
Index: llvm/lib/Support/Allocator.cpp
diff -u llvm/lib/Support/Allocator.cpp:1.2 llvm/lib/Support/Allocator.cpp:1.3
--- llvm/lib/Support/Allocator.cpp:1.2 Wed Nov 8 09:04:35 2006
+++ llvm/lib/Support/Allocator.cpp Sun Nov 26 04:52:51 2006
@@ -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 @@
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";
}
Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.78 llvm/lib/Support/CommandLine.cpp:1.79
--- llvm/lib/Support/CommandLine.cpp:1.78 Thu Oct 12 19:06:24 2006
+++ llvm/lib/Support/CommandLine.cpp Sun Nov 26 04:52:51 2006
@@ -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 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 @@
case ValueOptional:
break;
default:
- std::cerr << ProgramName
+ llvm_cerr << ProgramName
<< ": Bad ValueMask flag! CommandLine usage error:"
<< Handler->getValueExpectedFlag() << "\n";
abort();
@@ -468,8 +468,8 @@
}
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 @@
// 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 @@
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 @@
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 @@
// 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 @@
//
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 @@
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 @@
}
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 @@
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 @@
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 {
Index: llvm/lib/Support/GraphWriter.cpp
diff -u llvm/lib/Support/GraphWriter.cpp:1.5 llvm/lib/Support/GraphWriter.cpp:1.6
--- llvm/lib/Support/GraphWriter.cpp:1.5 Thu Aug 24 17:39:25 2006
+++ llvm/lib/Support/GraphWriter.cpp Sun Nov 26 04:52:51 2006
@@ -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 @@
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 @@
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 @@
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 @@
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;
Index: llvm/lib/Support/PluginLoader.cpp
diff -u llvm/lib/Support/PluginLoader.cpp:1.18 llvm/lib/Support/PluginLoader.cpp:1.19
--- llvm/lib/Support/PluginLoader.cpp:1.18 Fri Jul 7 12:14:04 2006
+++ llvm/lib/Support/PluginLoader.cpp Sun Nov 26 04:52:51 2006
@@ -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 @@
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);
Index: llvm/lib/Support/SlowOperationInformer.cpp
diff -u llvm/lib/Support/SlowOperationInformer.cpp:1.10 llvm/lib/Support/SlowOperationInformer.cpp:1.11
--- llvm/lib/Support/SlowOperationInformer.cpp:1.10 Mon Aug 7 18:20:15 2006
+++ llvm/lib/Support/SlowOperationInformer.cpp Sun Nov 26 04:52:51 2006
@@ -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 @@
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 @@
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 @@
OS << "% ";
LastPrintAmount = OS.str().size();
- std::cout << ToPrint+OS.str() << std::flush;
+ llvm_cout << ToPrint+OS.str() << std::flush;
return false;
}
Index: llvm/lib/Support/SystemUtils.cpp
diff -u llvm/lib/Support/SystemUtils.cpp:1.45 llvm/lib/Support/SystemUtils.cpp:1.46
--- llvm/lib/Support/SystemUtils.cpp:1.45 Thu Jul 7 18:21:43 2005
+++ llvm/lib/Support/SystemUtils.cpp Sun Nov 26 04:52:51 2006
@@ -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 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;
}
More information about the llvm-commits
mailing list