[Clang] Modify CXXMethodDecl::isMoveAssignmentOperator() to look through type sugar

AcceptedPublic

Currently CXXMethodDecl::isMoveAssignmentOperator() does not look though type
sugar and so if the parameter is a type alias it will not be able to detect
that the method is a move assignment operator. This PR fixes that and adds a set
of tests that covers that we correctly detect special member functions when
defaulting or deleting them.

This fixes: https://github.com/llvm/llvm-project/issues/56456

Differential Revision: https://reviews.llvm.org/D129591
This commit is contained in:
Shafik Yaghmour 2022-07-14 14:54:48 -07:00
parent 9913ea490a
commit 80dec2ecff
3 changed files with 28 additions and 1 deletions

View File

@ -186,6 +186,8 @@ Bug Fixes
- Clang now checks ODR violations when merging concepts from different modules.
Note that this may possibly break existing code, and is done so intentionally.
Fixes `Issue 56310 <https://github.com/llvm/llvm-project/issues/56310>`_.
- Clang will now look through type sugar when checking a member function is a
move assignment operator. Fixes `Issue 56456 <https://github.com/llvm/llvm-project/issues/56456>`_.
Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -2410,7 +2410,7 @@ bool CXXMethodDecl::isMoveAssignmentOperator() const {
return false;
QualType ParamType = getParamDecl(0)->getType();
if (!isa<RValueReferenceType>(ParamType))
if (!ParamType->isRValueReferenceType())
return false;
ParamType = ParamType->getPointeeType();

View File

@ -259,3 +259,28 @@ namespace P1286R2 {
static_assert(noexcept(A::B()), "");
}
namespace GH56456 {
template <typename T>
using RC=T const&;
template <typename T>
using RV=T&;
template <typename T>
using RM=T&&;
struct A {
A(RC<A>) = default;
A(RM<A>) = default;
auto operator=(RC<A>) -> RV<A> = default;
auto operator=(RM<A>) -> RV<A> = default;
};
struct B {
B (RC<B>) = delete;
B (RM<B>) = delete;
auto operator = (RC<B>) -> RV<B> = delete;
auto operator = (RM<B>) -> RV<B> = delete;
};
}