[Mlir-commits] [mlir] 57d239e - [mlir] Breakdown diagnostic string literals

Logan Chien llvmlistbot at llvm.org
Tue May 24 07:58:49 PDT 2022


Author: Logan Chien
Date: 2022-05-24T07:58:00-07:00
New Revision: 57d239e4ad110c052fe0c05fb25a588ec5a8de14

URL: https://github.com/llvm/llvm-project/commit/57d239e4ad110c052fe0c05fb25a588ec5a8de14
DIFF: https://github.com/llvm/llvm-project/commit/57d239e4ad110c052fe0c05fb25a588ec5a8de14.diff

LOG: [mlir] Breakdown diagnostic string literals

This commit breaks down diagnostic string literals so that the attribute
name and enumurator names can be shared with the stringify utility
function and the "expected ", " to be one of ", and ", " can be shared
between different enum-related diagnostic.

Differential Revision: https://reviews.llvm.org/D125938

Added: 
    

Modified: 
    mlir/include/mlir/IR/EnumAttr.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/EnumAttr.td b/mlir/include/mlir/IR/EnumAttr.td
index a655d3456acd6..ef2fd33b64e92 100644
--- a/mlir/include/mlir/IR/EnumAttr.td
+++ b/mlir/include/mlir/IR/EnumAttr.td
@@ -222,9 +222,10 @@ class IntEnumAttr<I intType, string name, string summary,
                           stringToSymbolFnName # [{(enumKeyword);
     if (maybeEnum)
       return *maybeEnum;
-    return {(::mlir::LogicalResult)$_parser.emitError(loc, "expected }] #
-    cppType # [{ to be one of: }] #
-    !interleave(!foreach(enum, enumerants, enum.str), ", ") # [{")};
+    return {(::mlir::LogicalResult)($_parser.emitError(loc) << "expected " }] #
+    [{<< "}] # cppType # [{" << " to be one of: " << }] #
+    !interleave(!foreach(enum, enumerants, "\"" # enum.str # "\""),
+                [{ << ", " << }]) # [{)};
   }()}];
   // Print the enum by calling `symbolToString`.
   let parameterPrinter = "$_printer << " # symbolToStringFnName # "($_self)";
@@ -294,10 +295,10 @@ class BitEnumAttr<I intType, string name, string summary,
       auto maybeEnum = }] # cppNamespace # "::" #
                             stringToSymbolFnName # [{(enumKeyword);
       if (!maybeEnum) {
-          return {(::mlir::LogicalResult)$_parser.emitError(loc, "expected }] #
-                  cppType # [{ to be one of: }] #
-                 !interleave(!foreach(enum, enumerants, enum.str),
-                             ", ") # [{")};
+          return {(::mlir::LogicalResult)($_parser.emitError(loc) << }] #
+              [{"expected " << "}] # cppType # [{" << " to be one of: " << }] #
+              !interleave(!foreach(enum, enumerants, "\"" # enum.str # "\""),
+                          [{ << ", " << }]) # [{)};
       }
       flags = flags | *maybeEnum;
     } while(::mlir::succeeded($_parser.}] # parseSeparatorFn # [{()));


        


More information about the Mlir-commits mailing list