[llvm] 97e544f - [ADT] Use C++17 fold expression in PointerSumType (NFC) (#159560)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 18 08:56:02 PDT 2025
Author: Kazu Hirata
Date: 2025-09-18T08:55:58-07:00
New Revision: 97e544f617a10011a5415b39a892de9d1aa88fd0
URL: https://github.com/llvm/llvm-project/commit/97e544f617a10011a5415b39a892de9d1aa88fd0
DIFF: https://github.com/llvm/llvm-project/commit/97e544f617a10011a5415b39a892de9d1aa88fd0.diff
LOG: [ADT] Use C++17 fold expression in PointerSumType (NFC) (#159560)
This patch simplifes the recursive Checker template with a C++17 fold
expression and "inlines" it right into the `static_assert`.
Added:
Modified:
llvm/include/llvm/ADT/PointerSumType.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/PointerSumType.h b/llvm/include/llvm/ADT/PointerSumType.h
index 132eab58b112a..c4971bf3af87a 100644
--- a/llvm/include/llvm/ADT/PointerSumType.h
+++ b/llvm/include/llvm/ADT/PointerSumType.h
@@ -239,19 +239,9 @@ struct PointerSumTypeHelper : MemberTs... {
TagMask = ~PointerMask
};
- // Finally we need a recursive template to do static checks of each
- // member.
- template <typename MemberT, typename... InnerMemberTs>
- struct Checker : Checker<InnerMemberTs...> {
- static_assert(MemberT::Tag < (1 << NumTagBits),
- "This discriminant value requires too many bits!");
- };
- template <typename MemberT> struct Checker<MemberT> : std::true_type {
- static_assert(MemberT::Tag < (1 << NumTagBits),
- "This discriminant value requires too many bits!");
- };
- static_assert(Checker<MemberTs...>::value,
- "Each member must pass the checker.");
+ // Finally, statically check each member.
+ static_assert(((MemberTs::Tag < (1 << NumTagBits)) && ...),
+ "A discriminant value requires too many bits!");
};
} // end namespace detail
More information about the llvm-commits
mailing list