mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-17 08:21:13 +00:00
Fix PDL verifiers to be resilient to invalid IR
This would cause a crash when calling `dump()` on an operation that didn't have a parent yet.
This commit is contained in:
parent
d3933a5d75
commit
eecce28ded
@ -48,7 +48,7 @@ static bool hasBindingUse(Operation *op) {
|
||||
/// is used by a "binding" operation. On failure, emits an error.
|
||||
static LogicalResult verifyHasBindingUse(Operation *op) {
|
||||
// If the parent is not a pattern, there is nothing to do.
|
||||
if (!isa<PatternOp>(op->getParentOp()))
|
||||
if (!llvm::isa_and_nonnull<PatternOp>(op->getParentOp()))
|
||||
return success();
|
||||
if (hasBindingUse(op))
|
||||
return success();
|
||||
@ -265,7 +265,7 @@ static LogicalResult verifyResultTypesAreInferrable(OperationOp op,
|
||||
}
|
||||
|
||||
LogicalResult OperationOp::verify() {
|
||||
bool isWithinRewrite = isa<RewriteOp>((*this)->getParentOp());
|
||||
bool isWithinRewrite = isa_and_nonnull<RewriteOp>((*this)->getParentOp());
|
||||
if (isWithinRewrite && !getOpName())
|
||||
return emitOpError("must have an operation name when nested within "
|
||||
"a `pdl.rewrite`");
|
||||
|
Loading…
x
Reference in New Issue
Block a user