Skip to content

Commit

Permalink
Add additional nullptr check for isDialectOp
Browse files Browse the repository at this point in the history
`getCalledFunction()` can return `nullptr`.
  • Loading branch information
Thomas Symalla authored and tsymalla-AMD committed Jun 11, 2024
1 parent 4e785a2 commit ec61062
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/TableGen/GenDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ void llvm_dialects::genDialectDefs(raw_ostream& out, RecordKeeper& records) {
}
bool $Dialect::isDialectOp(::llvm::CallInst& op) {
return isDialectOp(op.getCalledFunction()->getName());
::llvm::Function *calledFunc = op.getCalledFunction();
if (!calledFunc)
return false;
return isDialectOp(calledFunc->getName());
}
bool $Dialect::isDialectOp(::llvm::Function& func) {
Expand Down
6 changes: 5 additions & 1 deletion test/example/generated/ExampleDialect.cpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ namespace xd {
}

bool ExampleDialect::isDialectOp(::llvm::CallInst& op) {
return isDialectOp(op.getCalledFunction()->getName());
::llvm::Function *calledFunc = op.getCalledFunction();
if (!calledFunc)
return false;

return isDialectOp(calledFunc->getName());
}

bool ExampleDialect::isDialectOp(::llvm::Function& func) {
Expand Down

0 comments on commit ec61062

Please sign in to comment.