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

Matthias Springer llvmlistbot at llvm.org
Wed Jan 29 03:08:39 PST 2025


Ingo =?utf-8?q?Müller?= <ingomueller at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/124770 at github.com>


================
@@ -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()",
----------------
matthias-springer wrote:

I suspect that the order of the checks here matters. I.e., it should be safe to assume that it is a string attr. But to be sure, you could try to add another test case for `test.string_attr_with_type` in generic op syntax, where the attr is not a string attr.

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


More information about the Mlir-commits mailing list