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

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 7 00:29:33 PDT 2018


EricWF created this revision.
EricWF added reviewers: rsmith, rjmccall, majnemer, aaron.ballman.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D46515

Files:
  include/clang/AST/ComparisonCategories.h
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ComparisonCategories.cpp
  lib/AST/Decl.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGenCXX/cxx2a-compare.cpp
  test/CodeGenCXX/cxx2a-defaulted-compare.cpp
  test/SemaCXX/compare-cxx2a.cpp
  test/SemaCXX/constant-expression-cxx2a.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46515.145432.patch
Type: text/x-patch
Size: 143298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180507/a6ebfb34/attachment-0001.bin>


More information about the cfe-commits mailing list