forked from OSchip/llvm-project
Return nullptr on Region::getContainingOperation()/getContainingFunction() instead of asserting
This avoids crashing when trying to dump an operation nested in a region that isn't yet attached to an operation, which is quite useful when debugging. This alone won't be enough to print an unlink Operation, it'll display `<<UNLINKED INSTRUCTION>>`. -- PiperOrigin-RevId: 249496388
This commit is contained in:
parent
29c7929b13
commit
d5397f4efe
|
@ -289,12 +289,10 @@ Region *Region::getContainingRegion() {
|
|||
}
|
||||
|
||||
Operation *Region::getContainingOp() {
|
||||
assert(!container.isNull() && "no container");
|
||||
return container.dyn_cast<Operation *>();
|
||||
}
|
||||
|
||||
Function *Region::getContainingFunction() {
|
||||
assert(!container.isNull() && "no container");
|
||||
return container.dyn_cast<Function *>();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue