Add support for nulls in BasicBlock::Node::description.

Nulls aren't generally expected here, but this is a debugging utility
and in practice it's more useful to print nulls cleanly than to crash
while trying to dump out a CFG.

Change-Id: I405c1e51875655acaf4f9689b47e3e6a6b8751df
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344967
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2020-12-21 12:16:15 -05:00 committed by Skia Commit-Bot
parent e42716032b
commit cdff3fcba6

View File

@ -65,7 +65,13 @@ struct BasicBlock {
#ifdef SK_DEBUG
String description() const {
SkASSERT(fStatement || fExpression);
return fStatement ? (*fStatement)->description() : (*fExpression)->description();
if (fStatement) {
return *fStatement ? (*fStatement)->description() : "(null statement)";
} else if (fExpression) {
return *fExpression ? (*fExpression)->description() : "(null expression)";
} else {
return "(nothing)";
}
}
#endif