forked from OSchip/llvm-project
Fix crash in MLIR opaque attribute parser
An assertion is triggered when the dialect is malformed. Differential Revision: https://reviews.llvm.org/D117709
This commit is contained in:
parent
24bc072edb
commit
4b12f4b2b1
|
@ -833,6 +833,7 @@ Attribute Parser::parseDenseElementsAttr(Type attrType) {
|
|||
|
||||
/// Parse an opaque elements attribute.
|
||||
Attribute Parser::parseOpaqueElementsAttr(Type attrType) {
|
||||
llvm::SMLoc loc = getToken().getLoc();
|
||||
consumeToken(Token::kw_opaque);
|
||||
if (parseToken(Token::less, "expected '<' after 'opaque'"))
|
||||
return nullptr;
|
||||
|
@ -857,7 +858,8 @@ Attribute Parser::parseOpaqueElementsAttr(Type attrType) {
|
|||
std::string data;
|
||||
if (parseElementAttrHexValues(*this, hexTok, data))
|
||||
return nullptr;
|
||||
return OpaqueElementsAttr::get(builder.getStringAttr(name), type, data);
|
||||
return getChecked<OpaqueElementsAttr>(loc, builder.getStringAttr(name), type,
|
||||
data);
|
||||
}
|
||||
|
||||
/// Shaped type for elements attribute.
|
||||
|
|
|
@ -645,3 +645,7 @@ func @erroneous_fields() {
|
|||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// expected-error @+1 {{invalid dialect namespace '"string with space"'}}
|
||||
#invalid_dialect = opaque<"string with space", "0xDEADBEEF"> : tensor<100xi32>
|
||||
|
|
Loading…
Reference in New Issue