[llvm] bd9554f - [ADT][NFC] UniqueFunction MSVC fix (#208293)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 8 12:48:58 PDT 2026
Author: Alexis Engelke
Date: 2026-07-08T19:48:53Z
New Revision: bd9554f5da14d3a627fb8effc1769541ca05e4f9
URL: https://github.com/llvm/llvm-project/commit/bd9554f5da14d3a627fb8effc1769541ca05e4f9
DIFF: https://github.com/llvm/llvm-project/commit/bd9554f5da14d3a627fb8effc1769541ca05e4f9.diff
LOG: [ADT][NFC] UniqueFunction MSVC fix (#208293)
Fixup of #208251 for MSVC, which erroneously treats uses of non-static
constexpr variables as odr-use and requires them to be captured.
Added:
Modified:
llvm/include/llvm/ADT/FunctionExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index a1e2077659ffb..4d8f18e4cb3dc 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -140,8 +140,10 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
// (We always store a T, even if the call will use a pointer to const T).
template <typename CallableT, typename CalledAsT>
UniqueFunctionBase(CallableT Callable, CalledAs<CalledAsT>) {
- constexpr bool UsesInlineStorage = sizeof(CallableT) <= InlineStorageSize &&
- alignof(CallableT) <= InlineStorageAlign;
+ // static as workaround an MSVC bug which treats constexpr uses as odr-uses.
+ static constexpr bool UsesInlineStorage =
+ sizeof(CallableT) <= InlineStorageSize &&
+ alignof(CallableT) <= InlineStorageAlign;
void *CallableAddr = &Storage.Inline;
if constexpr (!UsesInlineStorage) {
CallableAddr = allocate_buffer(sizeof(CallableT), alignof(CallableT));
More information about the llvm-commits
mailing list