[Mlir-commits] [mlir] [mlir] Fix integer overflow in ShapedType::getNumElements (PR #178395)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jan 28 10:34:24 PST 2026


mugiwaraluffy56 wrote:

@sweiglbosker Thanks for taking a look!

You're probably right about moving this to the verifier/parser instead. I was trying to catch it at the API level but I can see why that's not ideal. 

For the getter wrapping , honestly I wasn't sure about the best design here. Would it make more sense to have:
- `getNumElements()` stay as-is (just with an assertion)
- Add something like `tryGetNumElements()` that returns std::optional?

Or should I just move all this checking somewhere else entirely?

And yeah, my bad on submitting without fully understanding the codebase architecture. Will be more careful about that.

Let me know what approach you'd prefer and I can rework this.

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


More information about the Mlir-commits mailing list