[Mlir-commits] [mlir] [MLIR] Fix parsed integers exceeding the expected bitwidth (PR #119971)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Sun Dec 15 14:08:50 PST 2024


================
@@ -710,12 +711,36 @@ class AsmParser {
   virtual ParseResult parseFloat(const llvm::fltSemantics &semantics,
                                  APFloat &result) = 0;
 
+  /// Parse an integer value from the stream.
+  ParseResult parseInteger(APInt &result, unsigned bitWidth,
+                           IntegerType::SignednessSemantics signedness) {
+    auto loc = getCurrentLocation();
+    APInt apintResult;
+    OptionalParseResult parseResult = parseOptionalInteger(apintResult);
+    if (!parseResult.has_value() || failed(*parseResult))
+      return emitError(loc, "expected integer value");
----------------
ftynse wrote:

Please add tests for all user-visible error messages.

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


More information about the Mlir-commits mailing list