[PATCH] D129591: Modify CXXMethodDecl::isMoveAssignmentOperator() to look through type sugar
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 12 13:59:17 PDT 2022
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane.
Herald added a project: All.
shafik requested review of this revision.
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
https://reviews.llvm.org/D129591
Files:
clang/lib/AST/DeclCXX.cpp
clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
Index: clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
===================================================================
--- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -259,3 +259,28 @@
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;
+};
+}
Index: clang/lib/AST/DeclCXX.cpp
===================================================================
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2410,7 +2410,7 @@
return false;
QualType ParamType = getParamDecl(0)->getType();
- if (!isa<RValueReferenceType>(ParamType))
+ if (!ParamType->isRValueReferenceType())
return false;
ParamType = ParamType->getPointeeType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129591.444075.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220712/15b152a8/attachment.bin>
More information about the cfe-commits
mailing list