Author: Sirraide Date: 2026-07-27T19:49:43Z New Revision: 6534ceefd231771466abc9c388b93bb8b0913316
URL: https://github.com/llvm/llvm-project/commit/6534ceefd231771466abc9c388b93bb8b0913316 DIFF: https://github.com/llvm/llvm-project/commit/6534ceefd231771466abc9c388b93bb8b0913316.diff LOG: [Clang] [NFC] Update OptionalUnsigned ctor to only reject signed integers (#212321) Currently, the `OptionalUnsigned(int) = delete;` constructor means that constructing e.g. an `OptionalOrUnsigned<uint64_t>` from an `unsigned` fails because overload resolution is ambiguous (because `unsigned` -> `int` and `unsigned` -> `uint64_t` are both valid conversions). This patch adds a constraint to make sure the deleted constructor only catches signed integer types. This is needed for #212319. Added: Modified: clang/include/clang/Basic/OptionalUnsigned.h Removed: ################################################################################ diff --git a/clang/include/clang/Basic/OptionalUnsigned.h b/clang/include/clang/Basic/OptionalUnsigned.h index ded84857310dc..bea02deda8ac3 100644 --- a/clang/include/clang/Basic/OptionalUnsigned.h +++ b/clang/include/clang/Basic/OptionalUnsigned.h @@ -30,7 +30,9 @@ template <class T> struct OptionalUnsigned { OptionalUnsigned(T Val) : Rep(static_cast<underlying_type>(Val) + 1) { assert(has_value()); } - OptionalUnsigned(int) = delete; + + template <class U, std::enable_if_t<std::is_signed_v<U>, bool> = false> + OptionalUnsigned(U) = delete; constexpr static OptionalUnsigned fromInternalRepresentation(underlying_type Rep) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
