Fix automatic description for AnyTypeOf
authorGeoffrey Martin-Noble <gcmn@google.com>
Mon, 20 May 2019 17:32:55 +0000 (10:32 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 20 May 2019 20:49:53 +0000 (13:49 -0700)
    Unfortunately, this now gives a segfault if you pass it an empty list, similar to stringify. Given how fiddly this is, we should probably have a string join helper. I'll fix both of these using better tablegen helpers in a follow-up.

--

PiperOrigin-RevId: 249076849

mlir/include/mlir/IR/OpBase.td

index 5d17280..48c35e5 100644 (file)
@@ -271,7 +271,7 @@ class AnyTypeOf<list<Type> allowedTypes, string description = ""> : Type<
     !if(!eq(description, ""),
         // Join all allowed types' descriptions with " or " as the description
         // if not provided during template specialization
-        !foldl(/*init*/"", /*list*/allowedTypes, prev, cur,
+        !foldl(!head(allowedTypes).description, !tail(allowedTypes), prev, cur,
                prev # " or " # cur.description),
         // Otherwise use the provided one
         description)>;