[PATCH] D126194: [Concepts] Implement overload resolution for destructors (P0848)

Roy Jacobson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 23 04:41:08 PDT 2022


royjacobson created this revision.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements a necessary part of P0848, the overload resolution for destructors.
It is now possible to overload destructors based on constraints, and the eligible destructor
will be selected at the end of the class.

The approach this patch takes is to perform the overload resolution after instantiating the members
in Sema::InstantiateClass, and to remove from the CXXRecordDecl all declarations of non-selected
destructors.

This is the approach that I found that can satisfy the following requirements:

1. The overload resolution and constraint checking is performed after the other members are defined but before the type is complete. This is important because constraints can check other members of the class, but the result of the overload resolution can change the type traits (triviallity etc.) of the class.
2. The order of (visible) functions in the AST is kept. This is important because it affects ABI through the order of functions in the vtable.

Note: this is only enabled for CPP20 - I tested it without the CPP20 restriction and
all the tests passed, so I can remove the restriction. I slightly prefer to remove it because
it will be easier to get coverage for this and it seems safer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126194

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/class/class.dtor/p4.cpp
  clang/test/CXX/over/over.match/over.match.viable/p3.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126194.431331.patch
Type: text/x-patch
Size: 8639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220523/ddab87be/attachment-0001.bin>


More information about the cfe-commits mailing list