Skip to content

Commit

Permalink
[MSFT] Implicit InnerRefAttr printer crashes on null attributes
Browse files Browse the repository at this point in the history
Printers should *never* crash since they are used when printing asm
which doesn't verify.
  • Loading branch information
teqdruid committed Sep 19, 2023
1 parent 28d8983 commit 6132720
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Dialect/MSFT/MSFTOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,14 @@ static ParseResult parseImplicitInnerRef(OpAsmParser &p,
}
void printImplicitInnerRef(OpAsmPrinter &p, Operation *,
hw::InnerRefAttr innerRef) {
p << SymbolRefAttr::get(innerRef.getModule(),
{FlatSymbolRefAttr::get(innerRef.getName())});
MLIRContext *ctxt = innerRef.getContext();
StringRef innerRefNameStr, moduleStr;
if (innerRef.getName())
innerRefNameStr = innerRef.getName().getValue();
if (innerRef.getModule())
moduleStr = innerRef.getModule().getValue();
p << SymbolRefAttr::get(ctxt, moduleStr,
{FlatSymbolRefAttr::get(ctxt, innerRefNameStr)});
}

/// Parse an parameter list if present. Same format as HW dialect.
Expand Down

0 comments on commit 6132720

Please sign in to comment.