Avoid failing when attempting to print null Attribute.

This avoids segfaulting when dumping during debugging of failures.

PiperOrigin-RevId: 223449494
This commit is contained in:
Jacques Pienaar 2018-11-29 18:47:39 -08:00 committed by jpienaar
parent a619b5c295
commit 21ed46abb8
1 changed files with 5 additions and 0 deletions

View File

@ -408,6 +408,11 @@ void ModulePrinter::printFunctionReference(const Function *func) {
}
void ModulePrinter::printAttribute(Attribute attr) {
if (!attr) {
os << "<<NULL ATTRIBUTE>>";
return;
}
switch (attr.getKind()) {
case Attribute::Kind::Bool:
os << (attr.cast<BoolAttr>().getValue() ? "true" : "false");