Skip to content

Commit 902cc53

Browse files
Fix possible crash by testing for isa<StringAttr first.
Signed-off-by: Ingo Müller <[email protected]>
1 parent 12b9d9b commit 902cc53

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

mlir/include/mlir/IR/CommonAttrConstraints.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,18 @@ class StringBasedAttr<Pred condition, string descr> : Attr<condition, descr> {
334334
let valueType = NoneType;
335335
}
336336

337-
def StrAttr : StringBasedAttr<CPred<"::llvm::isa<::mlir::StringAttr>($_self)">,
338-
"string attribute">;
337+
def StrAttrPred : CPred<"::llvm::isa<::mlir::StringAttr>($_self)">;
338+
339+
def StrAttr : StringBasedAttr<StrAttrPred, "string attribute">;
339340

340341
// A string attribute that represents the name of a symbol.
341-
def SymbolNameAttr : StringBasedAttr<CPred<"::llvm::isa<::mlir::StringAttr>($_self)">,
342-
"string attribute">;
342+
def SymbolNameAttr : StringBasedAttr<StrAttrPred, "string attribute">;
343343

344344
// String attribute that has a specific value type.
345345
class TypedStrAttr<Type ty>
346-
: StringBasedAttr<
346+
: StringBasedAttr<And<[StrAttrPred,
347347
SubstLeaves<"$_self", "::mlir::cast<StringAttr>($_self).getType()",
348-
ty.predicate>,
348+
ty.predicate>]>,
349349
"string attribute of " # ty.summary> {
350350
let valueType = ty;
351351
}

0 commit comments

Comments
 (0)