Skip to content

Commit ec61062

Browse files
Thomas Symallatsymalla-AMD
authored andcommitted
Add additional nullptr check for isDialectOp
`getCalledFunction()` can return `nullptr`.
1 parent 4e785a2 commit ec61062

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/TableGen/GenDialect.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ void llvm_dialects::genDialectDefs(raw_ostream& out, RecordKeeper& records) {
302302
}
303303
304304
bool $Dialect::isDialectOp(::llvm::CallInst& op) {
305-
return isDialectOp(op.getCalledFunction()->getName());
305+
::llvm::Function *calledFunc = op.getCalledFunction();
306+
if (!calledFunc)
307+
return false;
308+
309+
return isDialectOp(calledFunc->getName());
306310
}
307311
308312
bool $Dialect::isDialectOp(::llvm::Function& func) {

test/example/generated/ExampleDialect.cpp.inc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ namespace xd {
3131
}
3232

3333
bool ExampleDialect::isDialectOp(::llvm::CallInst& op) {
34-
return isDialectOp(op.getCalledFunction()->getName());
34+
::llvm::Function *calledFunc = op.getCalledFunction();
35+
if (!calledFunc)
36+
return false;
37+
38+
return isDialectOp(calledFunc->getName());
3539
}
3640

3741
bool ExampleDialect::isDialectOp(::llvm::Function& func) {

0 commit comments

Comments
 (0)