never be true in a well-defined context. The checking for null pointers
has been moved into the caller logic so it does not rely on undefined behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210497
91177308-0d34-0410-b5e6-
96231b3b80d8
bool runOnSCC(CallGraphSCC &SCC) override {
Out << Banner;
- for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I)
+ for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
+ assert((*I)->getFunction() && "Expecting non-null Function");
(*I)->getFunction()->print(Out);
+ }
return false;
}
};
OS << ")";
}
OS << " in ";
+ assert(UI->getUser() != nullptr && "Expected non-null User");
UI->getUser()->print(OS);
OS << '\n';
}
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);
}
return false;
bool runOnRegion(Region *R, RGPassManager &RGM) override {
Out << Banner;
- for (const auto &BB : R->blocks())
+ for (const auto &BB : R->blocks()) {
+ assert(BB != nullptr && "Expecting non-null Block");
BB->print(Out);
+ }
return false;
}
SmallString<8> StrVal;
CFP->getValueAPF().toString(StrVal);
+ assert(CFP->getType() != nullptr && "Expecting non-null Type");
CFP->getType()->print(AP.OutStreamer.GetCommentOS());
AP.OutStreamer.GetCommentOS() << ' ' << StrVal << '\n';
}
}
void Type::print(raw_ostream &OS) const {
- if (!this) {
- OS << "<null Type>";
- return;
- }
TypePrinting TP;
TP.print(const_cast<Type*>(this), OS);
}
void Value::print(raw_ostream &ROS) const {
- if (!this) {
- ROS << "printing a <null> value\n";
- return;
- }
formatted_raw_ostream OS(ROS);
if (const Instruction *I = dyn_cast<Instruction>(this)) {
const Function *F = I->getParent() ? I->getParent()->getParent() : nullptr;
std::string buf;
raw_string_ostream os(buf);
+ assert(unwrap(Ty) != nullptr && "Expecting non-null Type");
unwrap(Ty)->print(os);
os.flush();
std::string buf;
raw_string_ostream os(buf);
+ assert(unwrap(Val) != nullptr && "Expecting non-null Value");
unwrap(Val)->print(os);
os.flush();
}
std::string getTypeName(Type *T) {
+ assert(T != nullptr && "Expecting non-null Type");
std::string TypeName;
raw_string_ostream TypeStream(TypeName);
T->print(TypeStream);