This is an archive of the discontinued LLVM Phabricator instance.

[C++2a] Implement operator<=> Part 3: Add defaulted comparisons (WIP)
Needs ReviewPublic

Authored by EricWF on May 7 2018, 12:29 AM.

Details

Summary

This patch implements the = default semantics and default member generation. It depends on the two other patches before it.

This patch implements default comparison operators using the existing machinery for defaulting special members, even though defaulted comparisons are not technically "special members".

One oddity/issue is that the special member machinery caches lookup results as it processes the base classes and fields. These caches work because the lookup results for constructors/assignment operators/ect cannot change for a class type after that type is complete. However, the lookup results for comparison operators can change, because they can be declared outside of the class definition. As a result, comparison operator caches are specific to the context in which the lookup is done (ie. the record decl context). Although this is less effective, it still seems important to cache the results as the lookup is repeated multiple times when deducing if the function should be deleted, constexpr, noexcept, or to deduce the common comparison type.

Other than that I think these changes are mostly straight forward.

For the most part I don't think there is anything too weird in this change.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 145642.May 8 2018, 1:07 AM
  • Rebase off master.
  • Implement support for array members in defaulted comparisons.