[Mlir-commits] [mlir] [mlir] Make `TypedStrAttr` actually enforce the string type. (PR #124770)

Ingo Müller llvmlistbot at llvm.org
Tue Jan 28 07:44:37 PST 2025


================
@@ -343,8 +343,10 @@ def SymbolNameAttr : StringBasedAttr<CPred<"::llvm::isa<::mlir::StringAttr>($_se
 
 // String attribute that has a specific value type.
 class TypedStrAttr<Type ty>
-    : StringBasedAttr<CPred<"::llvm::isa<::mlir::StringAttr>($_self)">,
-                            "string attribute"> {
+    : StringBasedAttr<
+        SubstLeaves<"$_self", "::mlir::cast<StringAttr>($_self).getType()",
----------------
ingomueller-net wrote:

Can we assume at this point that the cast will succeed or should I test that `$_self` is `StringAttr` as well?

https://github.com/llvm/llvm-project/pull/124770


More information about the Mlir-commits mailing list