summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-23 22:45:37 +0000
committerChris Lattner <sabre@nondot.org>2009-08-23 22:45:37 +0000
commit74382b7c699120fbec5cb5603c9cf4212eb37f06 (patch)
treec8c2c5b8879b256c428b0d35841b9cce1c2cc51c /tools
parent983c592272eb59d39fd78c515e1f2701638879e0 (diff)
downloadllvm-74382b7c699120fbec5cb5603c9cf4212eb37f06.tar.gz
llvm-74382b7c699120fbec5cb5603c9cf4212eb37f06.tar.bz2
llvm-74382b7c699120fbec5cb5603c9cf4212eb37f06.tar.xz
Prune #includes from llvm/Linker.h and llvm/System/Path.h,
forcing them down into various .cpp files. This change also: 1. Renames TimeValue::toString() and Path::toString() to ::str() for similarity with the STL. 2. Removes all stream insertion support for sys::Path, forcing clients to call .str(). 3. Removes a use of Config/alloca.h from bugpoint, using smallvector instead. 4. Weans llvm-db off <iostream> sys::Path really needs to be gutted, but I don't have the desire to do it at this point. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/CrashDebugger.cpp4
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp15
-rw-r--r--tools/bugpoint/ExtractFunction.cpp1
-rw-r--r--tools/bugpoint/FindBugs.cpp1
-rw-r--r--tools/bugpoint/Miscompilation.cpp39
-rw-r--r--tools/bugpoint/OptimizerDriver.cpp38
-rw-r--r--tools/bugpoint/ToolRunner.cpp21
-rw-r--r--tools/lli/lli.cpp1
-rw-r--r--tools/llvm-ar/llvm-ar.cpp23
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp1
-rw-r--r--tools/llvm-db/Commands.cpp127
-rw-r--r--tools/llvm-db/llvm-db.cpp8
-rw-r--r--tools/llvm-ld/llvm-ld.cpp16
-rw-r--r--tools/llvm-link/llvm-link.cpp3
-rw-r--r--tools/lto/LTOCodeGenerator.cpp5
15 files changed, 156 insertions, 147 deletions
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 4e15732b6e..b348a0875e 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -72,10 +72,10 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
PrefixOutput.set(PfxOutput);
OrigProgram = BD.Program;
- BD.Program = ParseInputFile(PrefixOutput.toString(), BD.getContext());
+ BD.Program = ParseInputFile(PrefixOutput.str(), BD.getContext());
if (BD.Program == 0) {
errs() << BD.getToolName() << ": Error reading bitcode file '"
- << PrefixOutput << "'!\n";
+ << PrefixOutput.str() << "'!\n";
exit(1);
}
PrefixOutput.eraseFromDisk();
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index 3916957a62..72b9717641 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -18,6 +18,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/SystemUtils.h"
+#include "llvm/Support/raw_ostream.h"
#include <fstream>
using namespace llvm;
@@ -280,9 +281,9 @@ void BugDriver::compileProgram(Module *M) {
<< "\n";
exit(1);
}
- if (writeProgramToFile(BitcodeFile.toString(), M)) {
+ if (writeProgramToFile(BitcodeFile.str(), M)) {
errs() << ToolName << ": Error emitting bitcode to file '"
- << BitcodeFile << "'!\n";
+ << BitcodeFile.str() << "'!\n";
exit(1);
}
@@ -290,7 +291,7 @@ void BugDriver::compileProgram(Module *M) {
FileRemover BitcodeFileRemover(BitcodeFile, !SaveTemps);
// Actually compile the program!
- Interpreter->compileProgram(BitcodeFile.toString());
+ Interpreter->compileProgram(BitcodeFile.str());
}
@@ -315,7 +316,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
<< ErrMsg << "!\n";
exit(1);
}
- BitcodeFile = uniqueFilename.toString();
+ BitcodeFile = uniqueFilename.str();
if (writeProgramToFile(BitcodeFile, Program)) {
errs() << ToolName << ": Error emitting bitcode to file '"
@@ -338,7 +339,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
<< ErrMsg << "\n";
exit(1);
}
- OutputFile = uniqueFile.toString();
+ OutputFile = uniqueFile.str();
// Figure out which shared objects to run, if any.
std::vector<std::string> SharedObjs(AdditionalSOs);
@@ -393,7 +394,7 @@ std::string BugDriver::compileSharedObject(const std::string &BitcodeFile) {
GCC::FileType FT = SafeInterpreter->OutputCode(BitcodeFile, OutputFile);
std::string SharedObjectFile;
- if (gcc->MakeSharedObject(OutputFile.toString(), FT,
+ if (gcc->MakeSharedObject(OutputFile.str(), FT,
SharedObjectFile, AdditionalLinkerArgs))
exit(1);
@@ -447,7 +448,7 @@ bool BugDriver::diffProgram(const std::string &BitcodeFile,
std::string Error;
bool FilesDifferent = false;
if (int Diff = DiffFilesWithTolerance(sys::Path(ReferenceOutputFile),
- sys::Path(Output.toString()),
+ sys::Path(Output.str()),
AbsTolerance, RelTolerance, &Error)) {
if (Diff == 2) {
errs() << "While diffing output: " << Error << '\n';
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index b2e427c9bf..31982e17c6 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -29,6 +29,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
#include "llvm/System/Signals.h"
#include <set>
diff --git a/tools/bugpoint/FindBugs.cpp b/tools/bugpoint/FindBugs.cpp
index fd1f84b728..2c11d29f60 100644
--- a/tools/bugpoint/FindBugs.cpp
+++ b/tools/bugpoint/FindBugs.cpp
@@ -17,6 +17,7 @@
#include "BugDriver.h"
#include "ToolRunner.h"
#include "llvm/Pass.h"
+#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <ctime>
using namespace llvm;
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 9c14147295..57a4fc717f 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -826,8 +826,9 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
<< ErrMsg << "\n";
exit(1);
}
- if (BD.writeProgramToFile(TestModuleBC.toString(), Test)) {
- errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
+ if (BD.writeProgramToFile(TestModuleBC.str(), Test)) {
+ errs() << "Error writing bitcode to `" << TestModuleBC.str()
+ << "'\nExiting.";
exit(1);
}
delete Test;
@@ -840,16 +841,17 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
exit(1);
}
- if (BD.writeProgramToFile(SafeModuleBC.toString(), Safe)) {
- errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
+ if (BD.writeProgramToFile(SafeModuleBC.str(), Safe)) {
+ errs() << "Error writing bitcode to `" << SafeModuleBC.str()
+ << "'\nExiting.";
exit(1);
}
- std::string SharedObject = BD.compileSharedObject(SafeModuleBC.toString());
+ std::string SharedObject = BD.compileSharedObject(SafeModuleBC.str());
delete Safe;
// Run the code generator on the `Test' code, loading the shared library.
// The function returns whether or not the new output differs from reference.
- int Result = BD.diffProgram(TestModuleBC.toString(), SharedObject, false);
+ int Result = BD.diffProgram(TestModuleBC.str(), SharedObject, false);
if (Result)
errs() << ": still failing!\n";
@@ -899,8 +901,9 @@ bool BugDriver::debugCodeGenerator() {
exit(1);
}
- if (writeProgramToFile(TestModuleBC.toString(), ToCodeGen)) {
- errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
+ if (writeProgramToFile(TestModuleBC.str(), ToCodeGen)) {
+ errs() << "Error writing bitcode to `" << TestModuleBC.str()
+ << "'\nExiting.";
exit(1);
}
delete ToCodeGen;
@@ -913,31 +916,33 @@ bool BugDriver::debugCodeGenerator() {
exit(1);
}
- if (writeProgramToFile(SafeModuleBC.toString(), ToNotCodeGen)) {
- errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
+ if (writeProgramToFile(SafeModuleBC.str(), ToNotCodeGen)) {
+ errs() << "Error writing bitcode to `" << SafeModuleBC.str()
+ << "'\nExiting.";
exit(1);
}
- std::string SharedObject = compileSharedObject(SafeModuleBC.toString());
+ std::string SharedObject = compileSharedObject(SafeModuleBC.str());
delete ToNotCodeGen;
outs() << "You can reproduce the problem with the command line: \n";
if (isExecutingJIT()) {
- outs() << " lli -load " << SharedObject << " " << TestModuleBC;
+ outs() << " lli -load " << SharedObject << " " << TestModuleBC.str();
} else {
- outs() << " llc -f " << TestModuleBC << " -o " << TestModuleBC<< ".s\n";
- outs() << " gcc " << SharedObject << " " << TestModuleBC
- << ".s -o " << TestModuleBC << ".exe";
+ outs() << " llc -f " << TestModuleBC.str() << " -o " << TestModuleBC.str()
+ << ".s\n";
+ outs() << " gcc " << SharedObject << " " << TestModuleBC.str()
+ << ".s -o " << TestModuleBC.str() << ".exe";
#if defined (HAVE_LINK_R)
outs() << " -Wl,-R.";
#endif
outs() << "\n";
- outs() << " " << TestModuleBC << ".exe";
+ outs() << " " << TestModuleBC.str() << ".exe";
}
for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
outs() << " " << InputArgv[i];
outs() << '\n';
outs() << "The shared object was created with:\n llc -march=c "
- << SafeModuleBC << " -o temporary.c\n"
+ << SafeModuleBC.str() << " -o temporary.c\n"
<< " gcc -xc temporary.c -O2 -o " << SharedObject;
if (TargetTriple.getArch() == Triple::sparc)
outs() << " -G"; // Compile a shared library, `-G' for Sparc
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index ef41c43b5f..0c9037ff41 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -27,9 +27,9 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
#include "llvm/System/Program.h"
-#include "llvm/Config/alloca.h"
#define DONT_GET_PLUGIN_LOADER_OPTION
#include "llvm/Support/PluginLoader.h"
@@ -136,7 +136,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
<< ErrMsg << "\n";
return(1);
}
- OutputFilename = uniqueFilename.toString();
+ OutputFilename = uniqueFilename.str();
// set up the input file name
sys::Path inputFilename("bugpoint-input.bc");
@@ -152,29 +152,26 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
if (!ErrInfo.empty()) {
- errs() << "Error opening bitcode file: " << inputFilename << "\n";
+ errs() << "Error opening bitcode file: " << inputFilename.str() << "\n";
return 1;
}
WriteBitcodeToFile(Program, InFile);
InFile.close();
// setup the child process' arguments
- const char** args = (const char**)
- alloca(sizeof(const char*) *
- (Passes.size()+13+2*PluginLoader::getNumPlugins()+NumExtraArgs));
- int n = 0;
+ SmallVector<const char*, 8> Args;
sys::Path tool = sys::Program::FindProgramByName(ToolName);
if (UseValgrind) {
- args[n++] = "valgrind";
- args[n++] = "--error-exitcode=1";
- args[n++] = "-q";
- args[n++] = tool.c_str();
+ Args.push_back("valgrind");
+ Args.push_back("--error-exitcode=1");
+ Args.push_back("-q");
+ Args.push_back(tool.c_str());
} else
- args[n++] = ToolName;
+ Args.push_back(ToolName);
- args[n++] = "-as-child";
- args[n++] = "-child-output";
- args[n++] = OutputFilename.c_str();
+ Args.push_back("-as-child");
+ Args.push_back("-child-output");
+ Args.push_back(OutputFilename.c_str());
std::vector<std::string> pass_args;
for (unsigned i = 0, e = PluginLoader::getNumPlugins(); i != e; ++i) {
pass_args.push_back( std::string("-load"));
@@ -185,11 +182,11 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
pass_args.push_back( std::string("-") + (*I)->getPassArgument() );
for (std::vector<std::string>::const_iterator I = pass_args.begin(),
E = pass_args.end(); I != E; ++I )
- args[n++] = I->c_str();
- args[n++] = inputFilename.c_str();
+ Args.push_back(I->c_str());
+ Args.push_back(inputFilename.c_str());
for (unsigned i = 0; i < NumExtraArgs; ++i)
- args[n++] = *ExtraArgs;
- args[n++] = 0;
+ Args.push_back(*ExtraArgs);
+ Args.push_back(0);
sys::Path prog;
if (UseValgrind)
@@ -201,7 +198,8 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
sys::Path Nowhere;
const sys::Path *Redirects[3] = {0, &Nowhere, &Nowhere};
- int result = sys::Program::ExecuteAndWait(prog, args, 0, (SilencePasses ? Redirects : 0),
+ int result = sys::Program::ExecuteAndWait(prog, Args.data(), 0,
+ (SilencePasses ? Redirects : 0),
Timeout, MemoryLimit, &ErrMsg);
// If we are supposed to delete the bitcode file or if the passes crashed,
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index 01afc20bad..e3e1cae4e5 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -13,11 +13,12 @@
#define DEBUG_TYPE "toolrunner"
#include "ToolRunner.h"
-#include "llvm/Config/config.h" // for HAVE_LINK_R
#include "llvm/System/Program.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Config/config.h" // for HAVE_LINK_R
#include <fstream>
#include <sstream>
using namespace llvm;
@@ -232,7 +233,7 @@ AbstractInterpreter *AbstractInterpreter::createLLI(const char *Argv0,
std::string &Message,
const std::vector<std::string> *ToolArgs) {
std::string LLIPath =
- FindExecutable("lli", Argv0, (void *)(intptr_t)&createLLI).toString();
+ FindExecutable("lli", Argv0, (void *)(intptr_t)&createLLI).str();
if (!LLIPath.empty()) {
Message = "Found lli: " + LLIPath + "\n";
return new LLI(LLIPath, ToolArgs);
@@ -332,7 +333,7 @@ AbstractInterpreter *AbstractInterpreter::createCustom(
pos = ExecCommandLine.find_first_of(delimiters, lastPos);
}
- std::string CmdPath = sys::Program::FindProgramByName(Command).toString();
+ std::string CmdPath = sys::Program::FindProgramByName(Command).str();
if (CmdPath.empty()) {
Message =
std::string("Cannot find '") + Command +
@@ -407,7 +408,7 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
GCCArgs.insert(GCCArgs.end(), gccArgs.begin(), gccArgs.end());
// Assuming LLC worked, compile the result with GCC and run it.
- return gcc->ExecuteProgram(OutputAsmFile.toString(), Args, GCC::AsmFile,
+ return gcc->ExecuteProgram(OutputAsmFile.str(), Args, GCC::AsmFile,
InputFile, OutputFile, GCCArgs,
Timeout, MemoryLimit);
}
@@ -419,7 +420,7 @@ LLC *AbstractInterpreter::createLLC(const char *Argv0,
const std::vector<std::string> *Args,
const std::vector<std::string> *GCCArgs) {
std::string LLCPath =
- FindExecutable("llc", Argv0, (void *)(intptr_t)&createLLC).toString();
+ FindExecutable("llc", Argv0, (void *)(intptr_t)&createLLC).str();
if (LLCPath.empty()) {
Message = "Cannot find `llc' in executable directory or PATH!\n";
return 0;
@@ -505,7 +506,7 @@ int JIT::ExecuteProgram(const std::string &Bitcode,
AbstractInterpreter *AbstractInterpreter::createJIT(const char *Argv0,
std::string &Message, const std::vector<std::string> *Args) {
std::string LLIPath =
- FindExecutable("lli", Argv0, (void *)(intptr_t)&createJIT).toString();
+ FindExecutable("lli", Argv0, (void *)(intptr_t)&createJIT).str();
if (!LLIPath.empty()) {
Message = "Found lli: " + LLIPath + "\n";
return new JIT(LLIPath, Args);
@@ -572,7 +573,7 @@ int CBE::ExecuteProgram(const std::string &Bitcode,
std::vector<std::string> GCCArgs(ArgsForGCC);
GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
- return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile,
+ return gcc->ExecuteProgram(OutputCFile.str(), Args, GCC::CFile,
InputFile, OutputFile, GCCArgs,
Timeout, MemoryLimit);
}
@@ -591,7 +592,7 @@ CBE *AbstractInterpreter::createCBE(const char *Argv0,
return 0;
}
- Message = "Found llc: " + LLCPath.toString() + "\n";
+ Message = "Found llc: " + LLCPath.str() + "\n";
GCC *gcc = GCC::create(Message, GCCArgs);
if (!gcc) {
errs() << Message << "\n";
@@ -757,7 +758,7 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
errs() << "Error making unique filename: " << ErrMsg << "\n";
exit(1);
}
- OutputFile = uniqueFilename.toString();
+ OutputFile = uniqueFilename.str();
std::vector<const char*> GCCArgs;
@@ -839,6 +840,6 @@ GCC *GCC::create(std::string &Message,
if (!RemoteClient.empty())
RemoteClientPath = sys::Program::FindProgramByName(RemoteClient);
- Message = "Found gcc: " + GCCPath.toString() + "\n";
+ Message = "Found gcc: " + GCCPath.str() + "\n";
return new GCC(GCCPath, RemoteClientPath, Args);
}
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 9c8cc6c08f..e5c1070bbb 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -28,6 +28,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Process.h"
#include "llvm/System/Signals.h"
#include "llvm/Target/TargetSelect.h"
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index c31f86ec5f..95957df53f 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -364,7 +364,7 @@ bool doPrint(std::string* ErrMsg) {
continue;
if (Verbose)
- std::cout << "Printing " << I->getPath().toString() << "\n";
+ std::cout << "Printing " << I->getPath().str() << "\n";
unsigned len = I->getSize();
std::cout.write(data, len);
@@ -422,11 +422,10 @@ doDisplayTable(std::string* ErrMsg) {
std::cout << " " << std::setw(4) << I->getUser();
std::cout << "/" << std::setw(4) << I->getGroup();
std::cout << " " << std::setw(8) << I->getSize();
- std::cout << " " << std::setw(20) <<
- I->getModTime().toString().substr(4);
- std::cout << " " << I->getPath().toString() << "\n";
+ std::cout << " " << std::setw(20) << I->getModTime().str().substr(4);
+ std::cout << " " << I->getPath().str() << "\n";
} else {
- std::cout << I->getPath().toString() << "\n";
+ std::cout << I->getPath().str() << "\n";
}
}
}
@@ -528,7 +527,7 @@ doMove(std::string* ErrMsg) {
if (AddBefore || InsertBefore || AddAfter) {
for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
I != E; ++I ) {
- if (RelPos == I->getPath().toString()) {
+ if (RelPos == I->getPath().str()) {
if (AddAfter) {
moveto_spot = I;
moveto_spot++;
@@ -616,7 +615,7 @@ doReplaceOrInsert(std::string* ErrMsg) {
std::set<sys::Path>::iterator found = remaining.end();
for (std::set<sys::Path>::iterator RI = remaining.begin(),
RE = remaining.end(); RI != RE; ++RI ) {
- std::string compare(RI->toString());
+ std::string compare(RI->str());
if (TruncateNames && compare.length() > 15) {
const char* nm = compare.c_str();
unsigned len = compare.length();
@@ -629,7 +628,7 @@ doReplaceOrInsert(std::string* ErrMsg) {
len = 15;
compare.assign(nm,len);
}
- if (compare == I->getPath().toString()) {
+ if (compare == I->getPath().str()) {
found = RI;
break;
}
@@ -661,9 +660,9 @@ doReplaceOrInsert(std::string* ErrMsg) {
}
// Determine if this is the place where we should insert
- if ((AddBefore || InsertBefore) && (RelPos == I->getPath().toString()))
+ if ((AddBefore || InsertBefore) && RelPos == I->getPath().str())
insert_spot = I;
- else if (AddAfter && (RelPos == I->getPath().toString())) {
+ else if (AddAfter && RelPos == I->getPath().str()) {
insert_spot = I;
insert_spot++;
}
@@ -719,14 +718,14 @@ int main(int argc, char **argv) {
if (!ArchivePath.exists()) {
// Produce a warning if we should and we're creating the archive
if (!Create)
- errs() << argv[0] << ": creating " << ArchivePath.toString() << "\n";
+ errs() << argv[0] << ": creating " << ArchivePath.str() << "\n";
TheArchive = Archive::CreateEmpty(ArchivePath, Context);
TheArchive->writeToDisk();
} else {
std::string Error;
TheArchive = Archive::OpenAndLoad(ArchivePath, Context, &Error);
if (TheArchive == 0) {
- errs() << argv[0] << ": error loading '" << ArchivePath << "': "
+ errs() << argv[0] << ": error loading '" << ArchivePath.str() << "': "
<< Error << "!\n";
return 1;
}
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index db9b1312f0..7a8feca0e5 100644
--- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include <map>
#include <algorithm>
diff --git a/tools/llvm-db/Commands.cpp b/tools/llvm-db/Commands.cpp
index bd741a5089..d759dddecd 100644
--- a/tools/llvm-db/Commands.cpp
+++ b/tools/llvm-db/Commands.cpp
@@ -19,8 +19,8 @@
#include "llvm/Debugger/SourceFile.h"
#include "llvm/Debugger/InferiorProcess.h"
#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h"
-#include <iostream>
#include <cstdlib>
using namespace llvm;
@@ -56,7 +56,7 @@ void CLIDebugger::startProgramRunning() {
if (!Status)
throw Err;
if (TheProgramInfo->getProgramTimeStamp() != Status->getTimestamp()) {
- std::cout << "'" << Program << "' has changed; re-reading program.\n";
+ outs() << "'" << Program.str() << "' has changed; re-reading program.\n";
// Unload an existing program. This kills the program if necessary.
Dbg.unloadProgram();
@@ -64,11 +64,11 @@ void CLIDebugger::startProgramRunning() {
TheProgramInfo = 0;
CurrentFile = 0;
- Dbg.loadProgram(Program.toString(), Context);
+ Dbg.loadProgram(Program.str(), Context);
TheProgramInfo = new ProgramInfo(Dbg.getProgram());
}
- std::cout << "Starting program: " << Dbg.getProgramPath() << "\n";
+ outs() << "Starting program: " << Dbg.getProgramPath() << "\n";
Dbg.createProgram();
// There was no current frame.
@@ -83,7 +83,7 @@ bool CLIDebugger::printSourceLine(unsigned LineNo) {
const char *LineStart, *LineEnd;
CurrentFile->getSourceLine(LineNo-1, LineStart, LineEnd);
if (LineStart == 0) return true;
- std::cout << LineNo;
+ outs() << LineNo;
// If this is the line the program is currently stopped at, print a marker.
if (Dbg.isProgramRunning()) {
@@ -93,10 +93,10 @@ bool CLIDebugger::printSourceLine(unsigned LineNo) {
CurSFI);
if (CurLineNo == LineNo && CurrentFile == &CurSFI->getSourceText())
- std::cout << " ->";
+ outs() << " ->";
}
- std::cout << "\t" << std::string(LineStart, LineEnd) << "\n";
+ outs() << "\t" << std::string(LineStart, LineEnd) << "\n";
return false;
}
@@ -117,19 +117,19 @@ void CLIDebugger::printProgramLocation(bool PrintLocation) {
if (PrintLocation) {
// FIXME: print the current function arguments
if (const GlobalVariable *FuncDesc = SF.getFunctionDesc())
- std::cout << getProgramInfo().getFunction(FuncDesc).getSymbolicName();
+ outs() << getProgramInfo().getFunction(FuncDesc).getSymbolicName();
else
- std::cout << "<unknown function>";
+ outs() << "<unknown function>";
CurrentFile = &FileDesc->getSourceText();
- std::cout << " at " << CurrentFile->getFilename() << ":" << LineNo;
- if (ColNo) std::cout << ":" << ColNo;
- std::cout << "\n";
+ outs() << " at " << CurrentFile->getFilename() << ":" << LineNo;
+ if (ColNo) outs() << ":" << ColNo;
+ outs() << "\n";
}
if (printSourceLine(LineNo))
- std::cout << "<could not load source file>\n";
+ outs() << "<could not load source file>\n";
else {
LineListedStart = LineNo-ListSize/2+1;
if ((int)LineListedStart < 1) LineListedStart = 1;
@@ -241,14 +241,15 @@ void CLIDebugger::fileCommand(std::string &Options) {
// If requested, start the new program.
if (Prog.empty()) {
- std::cout << "Unloaded program.\n";
+ outs() << "Unloaded program.\n";
} else {
- std::cout << "Loading program... " << std::flush;
+ outs() << "Loading program... ";
+ outs().flush();
Dbg.loadProgram(Prog, Context);
assert(Dbg.isProgramLoaded() &&
"loadProgram succeeded, but not program loaded!");
TheProgramInfo = new ProgramInfo(Dbg.getProgram());
- std::cout << "successfully loaded '" << Dbg.getProgramPath() << "'!\n";
+ outs() << "successfully loaded '" << Dbg.getProgramPath() << "'!\n";
}
}
@@ -391,29 +392,29 @@ void CLIDebugger::backtraceCommand(std::string &Options) {
try {
for (unsigned i = 0; ; ++i) {
StackFrame &SF = RI.getStackFrame(i);
- std::cout << "#" << i;
+ outs() << "#" << i;
if (i == RI.getCurrentFrameIdx())
- std::cout << " ->";
- std::cout << "\t" << SF.getFrameID() << " in ";
+ outs() << " ->";
+ outs() << "\t" << SF.getFrameID() << " in ";
if (const GlobalVariable *G = SF.getFunctionDesc())
- std::cout << PI.getFunction(G).getSymbolicName();
+ outs() << PI.getFunction(G).getSymbolicName();
unsigned LineNo, ColNo;
const SourceFileInfo *SFI;
SF.getSourceLocation(LineNo, ColNo, SFI);
if (!SFI->getBaseName().empty()) {
- std::cout << " at " << SFI->getBaseName();
+ outs() << " at " << SFI->getBaseName();
if (LineNo) {
- std::cout << ":" << LineNo;
+ outs() << ":" << LineNo;
if (ColNo)
- std::cout << ":" << ColNo;
+ outs() << ":" << ColNo;
}
}
// FIXME: when we support shared libraries, we should print ' from foo.so'
// if the stack frame is from a different object than the current one.
- std::cout << "\n";
+ outs() << "\n";
}
} catch (...) {
// Stop automatically when we run off the bottom of the stack.
@@ -522,11 +523,11 @@ void CLIDebugger::infoCommand(std::string &Options) {
} else if (What == "functions") {
const std::map<const GlobalVariable*, SourceFunctionInfo*> &Functions
= getProgramInfo().getSourceFunctions();
- std::cout << "All defined functions:\n";
+ outs() << "All defined functions:\n";
// FIXME: GDB groups these by source file. We could do that I guess.
for (std::map<const GlobalVariable*, SourceFunctionInfo*>::const_iterator
I = Functions.begin(), E = Functions.end(); I != E; ++I) {
- std::cout << I->second->getSymbolicName() << "\n";
+ outs() << I->second->getSymbolicName() << "\n";
}
} else if (What == "source") {
@@ -537,30 +538,30 @@ void CLIDebugger::infoCommand(std::string &Options) {
const SourceFileInfo &SF =
getProgramInfo().getSourceFile(CurrentFile->getDescriptor());
- std::cout << "Current source file is: " << SF.getBaseName() << "\n"
- << "Compilation directory is: " << SF.getDirectory() << "\n";
+ outs() << "Current source file is: " << SF.getBaseName() << "\n"
+ << "Compilation directory is: " << SF.getDirectory() << "\n";
if (unsigned NL = CurrentFile->getNumLines())
- std::cout << "Located in: " << CurrentFile->getFilename() << "\n"
- << "Contains " << NL << " lines\n";
+ outs() << "Located in: " << CurrentFile->getFilename() << "\n"
+ << "Contains " << NL << " lines\n";
else
- std::cout << "Could not find source file.\n";
- std::cout << "Source language is "
- << SF.getLanguage().getSourceLanguageName() << "\n";
+ outs() << "Could not find source file.\n";
+ outs() << "Source language is "
+ << SF.getLanguage().getSourceLanguageName() << "\n";
} else if (What == "sources") {
const std::map<const GlobalVariable*, SourceFileInfo*> &SourceFiles =
getProgramInfo().getSourceFiles();
- std::cout << "Source files for the program:\n";
+ outs() << "Source files for the program:\n";
for (std::map<const GlobalVariable*, SourceFileInfo*>::const_iterator I =
SourceFiles.begin(), E = SourceFiles.end(); I != E;) {
- std::cout << I->second->getDirectory() << "/"
- << I->second->getBaseName();
+ outs() << I->second->getDirectory() << "/"
+ << I->second->getBaseName();
++I;
- if (I != E) std::cout << ", ";
+ if (I != E) outs() << ", ";
}
- std::cout << "\n";
+ outs() << "\n";
} else if (What == "target") {
- std::cout << Dbg.getRunningProcess().getStatus();
+ outs() << Dbg.getRunningProcess().getStatus();
} else {
// See if this is something handled by the current language.
if (getCurrentLanguage().printInfo(What))
@@ -746,7 +747,7 @@ void CLIDebugger::listCommand(std::string &Options) {
if (LineStart == 0)
throw "Could not load source file '" + CurrentFile->getFilename() + "'!";
else
- std::cout << "<end of file>\n";
+ outs() << "<end of file>\n";
}
}
@@ -762,11 +763,11 @@ void CLIDebugger::setCommand(std::string &Options) {
if (!getToken(Options).empty())
throw "set language expects one argument at most.";
if (Lang == "") {
- std::cout << "The currently understood settings are:\n\n"
- << "local or auto Automatic setting based on source file\n"
- << "c Use the C language\n"
- << "c++ Use the C++ language\n"
- << "unknown Use when source language is not supported\n";
+ outs() << "The currently understood settings are:\n\n"
+ << "local or auto Automatic setting based on source file\n"
+ << "c Use the C language\n"
+ << "c++ Use the C++ language\n"
+ << "unknown Use when source language is not supported\n";
} else if (Lang == "local" || Lang == "auto") {
CurrentLanguage = 0;
} else if (Lang == "c") {
@@ -799,28 +800,28 @@ void CLIDebugger::showCommand(std::string &Options) {
throw "show command expects one argument.";
if (What == "args") {
- std::cout << "Argument list to give program when started is \"";
+ outs() << "Argument list to give program when started is \"";
// FIXME: This doesn't print stuff correctly if the arguments have spaces in
// them, but currently the only way to get that is to use the --args command
// line argument. This should really handle escaping all hard characters as
// needed.
for (unsigned i = 0, e = Dbg.getNumProgramArguments(); i != e; ++i)
- std::cout << (i ? " " : "") << Dbg.getProgramArgument(i);
- std::cout << "\"\n";
+ outs() << (i ? " " : "") << Dbg.getProgramArgument(i);
+ outs() << "\"\n";
} else if (What == "language") {
- std::cout << "The current source language is '";
+ outs() << "The current source language is '";
if (CurrentLanguage)
- std::cout << CurrentLanguage->getSourceLanguageName();
+ outs() << CurrentLanguage->getSourceLanguageName();
else
- std::cout << "auto; currently "
- << getCurrentLanguage().getSourceLanguageName();
- std::cout << "'.\n";
+ outs() << "auto; currently "
+ << getCurrentLanguage().getSourceLanguageName();
+ outs() << "'.\n";
} else if (What == "listsize") {
- std::cout << "Number of source lines llvm-db will list by default is "
- << ListSize << ".\n";
+ outs() << "Number of source lines llvm-db will list by default is "
+ << ListSize << ".\n";
} else if (What == "prompt") {
- std::cout << "llvm-db's prompt is \"" << Prompt << "\".\n";
+ outs() << "llvm-db's prompt is \"" << Prompt << "\".\n";
} else {
throw "Unknown show command '" + What + "'. Try 'help show'.";
}
@@ -835,16 +836,16 @@ void CLIDebugger::helpCommand(std::string &Options) {
// Getting detailed help on a particular command?
if (!Command.empty()) {
CLICommand *C = getCommand(Command);
- std::cout << C->getShortHelp() << ".\n" << C->getLongHelp();
+ outs() << C->getShortHelp() << ".\n" << C->getLongHelp();
// If there are aliases for this option, print them out.
const std::vector<std::string> &Names = C->getOptionNames();
if (Names.size() > 1) {
- std::cout << "The '" << Command << "' command is known as: '"
- << Names[0] << "'";
+ outs() << "The '" << Command << "' command is known as: '"
+ << Names[0] << "'";
for (unsigned i = 1, e = Names.size(); i != e; ++i)
- std::cout << ", '" << Names[i] << "'";
- std::cout << "\n";
+ outs() << ", '" << Names[i] << "'";
+ outs() << "\n";
}
} else {
@@ -859,7 +860,7 @@ void CLIDebugger::helpCommand(std::string &Options) {
for (std::map<std::string, CLICommand*>::iterator I = CommandTable.begin(),
E = CommandTable.end(); I != E; ++I)
if (I->first == I->second->getPrimaryOptionName())
- std::cout << I->first << std::string(MaxSize - I->first.size(), ' ')
- << " - " << I->second->getShortHelp() << "\n";
+ outs() << I->first << std::string(MaxSize - I->first.size(), ' ')
+ << " - " << I->second->getShortHelp() << "\n";
}
}
diff --git a/tools/llvm-db/llvm-db.cpp b/tools/llvm-db/llvm-db.cpp
index 8fb9b5857e..463a1bdf88 100644
--- a/tools/llvm-db/llvm-db.cpp
+++ b/tools/llvm-db/llvm-db.cpp
@@ -17,8 +17,8 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
-#include <iostream>
using namespace llvm;
namespace {
@@ -57,13 +57,13 @@ int main(int argc, char **argv, char * const *envp) {
LLVMContext &Context = getGlobalContext();
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
- std::cout << "NOTE: llvm-db is known useless right now.\n";
+ outs() << "NOTE: llvm-db is known useless right now.\n";
try {
cl::ParseCommandLineOptions(argc, argv,
"llvm source-level debugger\n");
if (!Quiet)
- std::cout << "llvm-db: The LLVM source-level debugger\n";
+ outs() << "llvm-db: The LLVM source-level debugger\n";
// Merge Inputfile and InputArgs into the InputArgs list...
if (!InputFile.empty() && InputArgs.empty())
@@ -85,7 +85,7 @@ int main(int argc, char **argv, char * const *envp) {
try {
D.fileCommand(InputArgs[0]);
} catch (const std::string &Error) {
- std::cout << "Error: " << Error << "\n";
+ outs() << "Error: " << Error << "\n";
}
Dbg.setProgramArguments(InputArgs.begin()+1, InputArgs.end());
diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp
index f789b15d3a..8fcaefde0b 100644
--- a/tools/llvm-ld/llvm-ld.cpp
+++ b/tools/llvm-ld/llvm-ld.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/SystemUtils.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
#include <memory>
@@ -466,7 +467,7 @@ static void EmitShellScript(char **argv) {
if (FullLibraryPath.isEmpty())
FullLibraryPath = sys::Path::FindLibrary(*i);
if (!FullLibraryPath.isEmpty())
- Out2 << " -load=" << FullLibraryPath.toString() << " \\\n";
+ Out2 << " -load=" << FullLibraryPath.str() << " \\\n";
}
Out2 << " " << BitcodeOutputFilename << " ${1+\"$@\"}\n";
Out2.close();
@@ -572,7 +573,7 @@ int main(int argc, char **argv, char **envp) {
sys::Path ExeFile( OutputFilename );
if (ExeFile.getSuffix() == "") {
ExeFile.appendSuffix("exe");
- OutputFilename = ExeFile.toString();
+ OutputFilename = ExeFile.str();
}
}
#endif
@@ -652,11 +653,11 @@ int main(int argc, char **argv, char **envp) {
// Generate an assembly language file for the bitcode.
std::string ErrMsg;
- if (0 != GenerateAssembly(AssemblyFile.toString(), BitcodeOutputFilename,
+ if (0 != GenerateAssembly(AssemblyFile.str(), BitcodeOutputFilename,
llc, ErrMsg))
PrintAndExit(ErrMsg);
- if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(),
+ if (0 != GenerateNative(OutputFilename, AssemblyFile.str(),
NativeLinkItems, gcc, envp, ErrMsg))
PrintAndExit(ErrMsg);
@@ -682,12 +683,11 @@ int main(int argc, char **argv, char **envp) {
// Generate an assembly language file for the bitcode.
std::string ErrMsg;
- if (0 != GenerateCFile(
- CFile.toString(), BitcodeOutputFilename, llc, ErrMsg))
+ if (GenerateCFile(CFile.str(), BitcodeOutputFilename, llc, ErrMsg))
PrintAndExit(ErrMsg);
- if (0 != GenerateNative(OutputFilename, CFile.toString(),
- NativeLinkItems, gcc, envp, ErrMsg))
+ if (GenerateNative(OutputFilename, CFile.str(),
+ NativeLinkItems, gcc, envp, ErrMsg))
PrintAndExit(ErrMsg);
// Remove the assembly language file.
diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp
index cebfec3fce..6dc04e6722 100644
--- a/tools/llvm-link/llvm-link.cpp
+++ b/tools/llvm-link/llvm-link.cpp
@@ -21,6 +21,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include "llvm/System/Path.h"
#include <memory>
@@ -58,7 +59,7 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN,
if (Verbose) errs() << "Loading '" << Filename.c_str() << "'\n";
Module* Result = 0;
- const std::string &FNStr = Filename.toString();
+ const std::string &FNStr = Filename.str();
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(FNStr,
&ErrorMessage)) {
Result = ParseBitcodeFile(Buffer, Context, &ErrorMessage);
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index e868ee312b..4bd754cfba 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -202,9 +202,8 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg)
sys::RemoveFileOnSignal(uniqueObjPath);
// assemble the assembly code
- const std::string& uniqueObjStr = uniqueObjPath.toString();
- bool asmResult = this->assemble(uniqueAsmPath.toString(),
- uniqueObjStr, errMsg);
+ const std::string& uniqueObjStr = uniqueObjPath.str();
+ bool asmResult = this->assemble(uniqueAsmPath.str(), uniqueObjStr, errMsg);
if ( !asmResult ) {
// remove old buffer if compile() called twice
delete _nativeObjectFile;