[Mlir-commits] [mlir] 9722a2c - [mlir][IR] Avoid Clang 21 crash during SFINAE overload resolution (#208359)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jul 9 08:27:00 PDT 2026
Author: Kazu Hirata
Date: 2026-07-09T08:26:56-07:00
New Revision: 9722a2ceddb6e4fc098f89c9c55c5ad7afd1a64c
URL: https://github.com/llvm/llvm-project/commit/9722a2ceddb6e4fc098f89c9c55c5ad7afd1a64c
DIFF: https://github.com/llvm/llvm-project/commit/9722a2ceddb6e4fc098f89c9c55c5ad7afd1a64c.diff
LOG: [mlir][IR] Avoid Clang 21 crash during SFINAE overload resolution (#208359)
Clang 21.1.8 segfaults during SFINAE overload resolution for
T::getChecked
when matching non-pointer arguments against an unconstrained
MLIRContext*
parameter.
This patch avoids the crash by adding an explicit SFINAE constraint to
the second overload of StorageUserBase::getChecked, ensuring that it is
only considered when the second argument is convertible to MLIRContext*.
Assisted-by: Antigravity
Added:
Modified:
mlir/include/mlir/IR/StorageUniquerSupport.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/StorageUniquerSupport.h b/mlir/include/mlir/IR/StorageUniquerSupport.h
index 8959dab047103..85189b5793fc7 100644
--- a/mlir/include/mlir/IR/StorageUniquerSupport.h
+++ b/mlir/include/mlir/IR/StorageUniquerSupport.h
@@ -194,9 +194,16 @@ class StorageUserBase : public BaseT, public Traits<ConcreteT>... {
/// Get or create a new ConcreteT instance within the ctx. If the arguments
/// provided are invalid, errors are emitted using the provided `emitError`
/// and a null object is returned.
- template <typename... Args>
+ ///
+ /// Workaround: We use Arg1 && instead of MLIRContext * in the parameter list
+ /// to work around a bug in Clang 21.1.8 where Clang segfaults during SFINAE
+ /// overload resolution when attempting to match non-pointer arguments
+ /// against an unconstrained MLIRContext * parameter.
+ template <typename Arg1, typename... Args,
+ typename = std::enable_if_t<std::is_convertible_v<
+ llvm::remove_cvref_t<Arg1>, MLIRContext *>>>
static ConcreteT getChecked(function_ref<InFlightDiagnostic()> emitErrorFn,
- MLIRContext *ctx, Args... args) {
+ Arg1 &&ctx, Args... args) {
// If the construction invariants fail then we return a null attribute.
if (failed(ConcreteT::verifyInvariants(emitErrorFn, args...)))
return ConcreteT();
More information about the Mlir-commits
mailing list