Add back functionality removed in r210497.

Instead of asserting, output a message stating that a null pointer was found.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211430 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Richard Trieu 2014-06-21 02:43:02 +00:00
parent 5d0ff9c928
commit 7921239c41
7 changed files with 34 additions and 16 deletions

View File

@ -603,8 +603,10 @@ namespace {
bool runOnSCC(CallGraphSCC &SCC) override {
Out << Banner;
for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
assert((*I)->getFunction() && "Expecting non-null Function");
(*I)->getFunction()->print(Out);
if ((*I)->getFunction())
(*I)->getFunction()->print(Out);
else
Out << "Printing <null> Function";
}
return false;
}

View File

@ -287,8 +287,10 @@ void IVUsers::print(raw_ostream &OS, const Module *M) const {
OS << ")";
}
OS << " in ";
assert(UI->getUser() != nullptr && "Expected non-null User");
UI->getUser()->print(OS);
if (UI->getUser())
UI->getUser()->print(OS);
else
OS << "Printing <null> User";
OS << '\n';
}
}

View File

@ -45,8 +45,10 @@ public:
for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
b != be;
++b) {
assert((*b) != nullptr && "Expecting non-null block");
(*b)->print(Out);
if (*b)
(*b)->print(Out);
else
Out << "Printing <null> block";
}
return false;
}

View File

@ -196,8 +196,10 @@ public:
bool runOnRegion(Region *R, RGPassManager &RGM) override {
Out << Banner;
for (const auto &BB : R->blocks()) {
assert(BB != nullptr && "Expecting non-null Block");
BB->print(Out);
if (BB)
BB->print(Out);
else
Out << "Printing <null> Block";
}
return false;

View File

@ -1866,8 +1866,10 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) {
SmallString<8> StrVal;
CFP->getValueAPF().toString(StrVal);
assert(CFP->getType() != nullptr && "Expecting non-null Type");
CFP->getType()->print(AP.OutStreamer.GetCommentOS());
if (CFP->getType())
CFP->getType()->print(AP.OutStreamer.GetCommentOS());
else
AP.OutStreamer.GetCommentOS() << "Printing <null> Type";
AP.OutStreamer.GetCommentOS() << ' ' << StrVal << '\n';
}

View File

@ -281,8 +281,11 @@ char *LLVMPrintTypeToString(LLVMTypeRef Ty) {
std::string buf;
raw_string_ostream os(buf);
assert(unwrap(Ty) != nullptr && "Expecting non-null Type");
unwrap(Ty)->print(os);
if (unwrap(Ty))
unwrap(Ty)->print(os);
else
os << "Printing <null> Type";
os.flush();
return strdup(buf.c_str());
@ -532,8 +535,11 @@ char* LLVMPrintValueToString(LLVMValueRef Val) {
std::string buf;
raw_string_ostream os(buf);
assert(unwrap(Val) != nullptr && "Expecting non-null Value");
unwrap(Val)->print(os);
if (unwrap(Val))
unwrap(Val)->print(os);
else
os << "Printing <null> Value";
os.flush();
return strdup(buf.c_str());

View File

@ -352,10 +352,12 @@ private:
}
std::string getTypeName(Type *T) {
assert(T != nullptr && "Expecting non-null Type");
std::string TypeName;
raw_string_ostream TypeStream(TypeName);
T->print(TypeStream);
if (T)
T->print(TypeStream);
else
TypeStream << "Printing <null> Type";
TypeStream.flush();
return TypeName;
}