Improve the representation of <compare>'s zero-only type.
* Use an empty struct instead of a member pointer to represent this type, so that we don't actually pass a zero member pointer at runtime. * Mark the constructor as consteval to ensure that no code is emitted for it whenever possible. * Add a honeypot constructor to reject all non-int arguments, so that the only argument that can arrive at the real constructor is the literal 0. This results in better generated code, and rejecting invalid comparisons against nullptr, 0L, and so on, while also rejecting invalid comparisons against (1-1) and similar that would be allowed if we required an integer constant expression with value 0. Differential Revision: https://reviews.llvm.org/D85051
Loading
Please sign in to comment