Convert more tools code from cerr and cout to errs() and outs().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76070 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-07-16 15:30:09 +00:00
parent ad60f660c6
commit ac95cc79ac
21 changed files with 278 additions and 285 deletions

View File

@@ -25,7 +25,6 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <iostream>
#include <memory>
using namespace llvm;
@@ -107,14 +106,14 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
if (Program == 0) return true;
if (!run_as_child)
std::cout << "Read input file : '" << Filenames[0] << "'\n";
outs() << "Read input file : '" << Filenames[0] << "'\n";
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
std::auto_ptr<Module> M(ParseInputFile(Filenames[i], Context));
if (M.get() == 0) return true;
if (!run_as_child)
std::cout << "Linking in input file: '" << Filenames[i] << "'\n";
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
std::string ErrorMessage;
if (Linker::LinkModules(Program, M.get(), &ErrorMessage)) {
errs() << ToolName << ": error linking in '" << Filenames[i] << "': "
@@ -128,7 +127,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
}
if (!run_as_child)
std::cout << "*** All input ok\n";
outs() << "*** All input ok\n";
// All input files read successfully!
return false;
@@ -162,7 +161,7 @@ bool BugDriver::run() {
// file, then we know the compiler didn't crash, so try to diagnose a
// miscompilation.
if (!PassesToRun.empty()) {
std::cout << "Running selected passes on program to test for crash: ";
outs() << "Running selected passes on program to test for crash: ";
if (runPasses(PassesToRun))
return debugOptimizerCrash();
}
@@ -171,12 +170,12 @@ bool BugDriver::run() {
if (initializeExecutionEnvironment()) return true;
// Test to see if we have a code generator crash.
std::cout << "Running the code generator to test for a crash: ";
outs() << "Running the code generator to test for a crash: ";
try {
compileProgram(Program);
std::cout << '\n';
outs() << '\n';
} catch (ToolExecutionError &TEE) {
std::cout << TEE.what();
outs() << TEE.what();
return debugCodeGeneratorCrash();
}
@@ -187,7 +186,7 @@ bool BugDriver::run() {
//
bool CreatedOutput = false;
if (ReferenceOutputFile.empty()) {
std::cout << "Generating reference output from raw program: ";
outs() << "Generating reference output from raw program: ";
if(!createReferenceFile(Program)){
return debugCodeGeneratorCrash();
}
@@ -202,10 +201,10 @@ bool BugDriver::run() {
// Diff the output of the raw program against the reference output. If it
// matches, then we assume there is a miscompilation bug and try to
// diagnose it.
std::cout << "*** Checking the code generator...\n";
outs() << "*** Checking the code generator...\n";
try {
if (!diffProgram()) {
std::cout << "\n*** Output matches: Debugging miscompilation!\n";
outs() << "\n*** Output matches: Debugging miscompilation!\n";
return debugMiscompilation();
}
} catch (ToolExecutionError &TEE) {
@@ -213,8 +212,8 @@ bool BugDriver::run() {
return debugCodeGeneratorCrash();
}
std::cout << "\n*** Input program does not match reference diff!\n";
std::cout << "Debugging code generator problem!\n";
outs() << "\n*** Input program does not match reference diff!\n";
outs() << "Debugging code generator problem!\n";
try {
return debugCodeGenerator();
} catch (ToolExecutionError &TEE) {
@@ -227,18 +226,18 @@ void llvm::PrintFunctionList(const std::vector<Function*> &Funcs) {
unsigned NumPrint = Funcs.size();
if (NumPrint > 10) NumPrint = 10;
for (unsigned i = 0; i != NumPrint; ++i)
std::cout << " " << Funcs[i]->getName();
outs() << " " << Funcs[i]->getName();
if (NumPrint < Funcs.size())
std::cout << "... <" << Funcs.size() << " total>";
std::cout << std::flush;
outs() << "... <" << Funcs.size() << " total>";
outs().flush();
}
void llvm::PrintGlobalVariableList(const std::vector<GlobalVariable*> &GVs) {
unsigned NumPrint = GVs.size();
if (NumPrint > 10) NumPrint = 10;
for (unsigned i = 0; i != NumPrint; ++i)
std::cout << " " << GVs[i]->getName();
outs() << " " << GVs[i]->getName();
if (NumPrint < GVs.size())
std::cout << "... <" << GVs.size() << " total>";
std::cout << std::flush;
outs() << "... <" << GVs.size() << " total>";
outs().flush();
}