switch a couple things off std::ostream

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79816 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-08-23 04:02:03 +00:00
parent b93a9a66ba
commit 37f077a8da
2 changed files with 28 additions and 28 deletions

View File

@@ -11,8 +11,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "LLVMContextImpl.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "LLVMContextImpl.h"
#include "ConstantFold.h" #include "ConstantFold.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/GlobalValue.h" #include "llvm/GlobalValue.h"
@@ -27,6 +27,7 @@
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Mutex.h" #include "llvm/System/Mutex.h"
#include "llvm/System/RWMutex.h" #include "llvm/System/RWMutex.h"
#include "llvm/System/Threading.h" #include "llvm/System/Threading.h"
@@ -110,10 +111,11 @@ void Constant::destroyConstantImpl() {
while (!use_empty()) { while (!use_empty()) {
Value *V = use_back(); Value *V = use_back();
#ifndef NDEBUG // Only in -g mode... #ifndef NDEBUG // Only in -g mode...
if (!isa<Constant>(V)) if (!isa<Constant>(V)) {
DOUT << "While deleting: " << *this errs() << "While deleting: " << *this
<< "\n\nUse still stuck around after Def is destroyed: " << "\n\nUse still stuck around after Def is destroyed: "
<< *V << "\n\n"; << *V << "\n\n";
}
#endif #endif
assert(isa<Constant>(V) && "References remain to Constant being destroyed"); assert(isa<Constant>(V) && "References remain to Constant being destroyed");
Constant *CV = cast<Constant>(V); Constant *CV = cast<Constant>(V);

View File

@@ -65,7 +65,6 @@
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <algorithm> #include <algorithm>
#include <sstream>
#include <cstdarg> #include <cstdarg>
using namespace llvm; using namespace llvm;
@@ -116,7 +115,9 @@ namespace {
// What to do if verification fails. // What to do if verification fails.
Module *Mod; // Module we are verifying right now Module *Mod; // Module we are verifying right now
DominatorTree *DT; // Dominator Tree, caution can be null! DominatorTree *DT; // Dominator Tree, caution can be null!
std::stringstream msgs; // A stringstream to collect messages
std::string Messages;
raw_string_ostream MessagesStr;
/// InstInThisBlock - when verifying a basic block, keep track of all of the /// InstInThisBlock - when verifying a basic block, keep track of all of the
/// instructions we have seen so far. This allows us to do efficient /// instructions we have seen so far. This allows us to do efficient
@@ -127,20 +128,20 @@ namespace {
Verifier() Verifier()
: FunctionPass(&ID), : FunctionPass(&ID),
Broken(false), RealPass(true), action(AbortProcessAction), Broken(false), RealPass(true), action(AbortProcessAction),
DT(0), msgs( std::ios::app | std::ios::out ) {} DT(0), MessagesStr(Messages) {}
explicit Verifier(VerifierFailureAction ctn) explicit Verifier(VerifierFailureAction ctn)
: FunctionPass(&ID), : FunctionPass(&ID),
Broken(false), RealPass(true), action(ctn), DT(0), Broken(false), RealPass(true), action(ctn), DT(0),
msgs( std::ios::app | std::ios::out ) {} MessagesStr(Messages) {}
explicit Verifier(bool AB) explicit Verifier(bool AB)
: FunctionPass(&ID), : FunctionPass(&ID),
Broken(false), RealPass(true), Broken(false), RealPass(true),
action( AB ? AbortProcessAction : PrintMessageAction), DT(0), action( AB ? AbortProcessAction : PrintMessageAction), DT(0),
msgs( std::ios::app | std::ios::out ) {} MessagesStr(Messages) {}
explicit Verifier(DominatorTree &dt) explicit Verifier(DominatorTree &dt)
: FunctionPass(&ID), : FunctionPass(&ID),
Broken(false), RealPass(false), action(PrintMessageAction), Broken(false), RealPass(false), action(PrintMessageAction),
DT(&dt), msgs( std::ios::app | std::ios::out ) {} DT(&dt), MessagesStr(Messages) {}
bool doInitialization(Module &M) { bool doInitialization(Module &M) {
@@ -206,20 +207,20 @@ namespace {
/// ///
bool abortIfBroken() { bool abortIfBroken() {
if (!Broken) return false; if (!Broken) return false;
msgs << "Broken module found, "; MessagesStr << "Broken module found, ";
switch (action) { switch (action) {
default: llvm_unreachable("Unknown action"); default: llvm_unreachable("Unknown action");
case AbortProcessAction: case AbortProcessAction:
msgs << "compilation aborted!\n"; MessagesStr << "compilation aborted!\n";
cerr << msgs.str(); errs() << MessagesStr.str();
// Client should choose different reaction if abort is not desired // Client should choose different reaction if abort is not desired
abort(); abort();
case PrintMessageAction: case PrintMessageAction:
msgs << "verification continues.\n"; MessagesStr << "verification continues.\n";
cerr << msgs.str(); errs() << MessagesStr.str();
return false; return false;
case ReturnStatusAction: case ReturnStatusAction:
msgs << "compilation terminated.\n"; MessagesStr << "compilation terminated.\n";
return true; return true;
} }
} }
@@ -286,18 +287,17 @@ namespace {
void WriteValue(const Value *V) { void WriteValue(const Value *V) {
if (!V) return; if (!V) return;
if (isa<Instruction>(V)) { if (isa<Instruction>(V)) {
msgs << *V; MessagesStr << *V;
} else { } else {
WriteAsOperand(msgs, V, true, Mod); WriteAsOperand(MessagesStr, V, true, Mod);
msgs << "\n"; MessagesStr << "\n";
} }
} }
void WriteType(const Type *T) { void WriteType(const Type *T) {
if (!T) return; if (!T) return;
raw_os_ostream RO(msgs); MessagesStr << ' ';
RO << ' '; WriteTypeSymbolic(MessagesStr, T, Mod);
WriteTypeSymbolic(RO, T, Mod);
} }
@@ -307,7 +307,7 @@ namespace {
void CheckFailed(const Twine &Message, void CheckFailed(const Twine &Message,
const Value *V1 = 0, const Value *V2 = 0, const Value *V1 = 0, const Value *V2 = 0,
const Value *V3 = 0, const Value *V4 = 0) { const Value *V3 = 0, const Value *V4 = 0) {
msgs << Message.str() << "\n"; MessagesStr << Message.str() << "\n";
WriteValue(V1); WriteValue(V1);
WriteValue(V2); WriteValue(V2);
WriteValue(V3); WriteValue(V3);
@@ -317,7 +317,7 @@ namespace {
void CheckFailed(const Twine &Message, const Value* V1, void CheckFailed(const Twine &Message, const Value* V1,
const Type* T2, const Value* V3 = 0) { const Type* T2, const Value* V3 = 0) {
msgs << Message.str() << "\n"; MessagesStr << Message.str() << "\n";
WriteValue(V1); WriteValue(V1);
WriteType(T2); WriteType(T2);
WriteValue(V3); WriteValue(V3);
@@ -1764,8 +1764,6 @@ bool llvm::verifyModule(const Module &M, VerifierFailureAction action,
PM.run(const_cast<Module&>(M)); PM.run(const_cast<Module&>(M));
if (ErrorInfo && V->Broken) if (ErrorInfo && V->Broken)
*ErrorInfo = V->msgs.str(); *ErrorInfo = V->MessagesStr.str();
return V->Broken; return V->Broken;
} }
// vim: sw=2