[clang] 80dec2e - [Clang] Modify CXXMethodDecl::isMoveAssignmentOperator() to look through type sugar
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 14 16:10:00 PDT 2022
Author: Shafik Yaghmour
Date: 2022-07-14T16:09:52-07:00
New Revision: 80dec2ecfffe30f86ecfeec8f553b16bb992c48b
URL: https://github.com/llvm/llvm-project/commit/80dec2ecfffe30f86ecfeec8f553b16bb992c48b
DIFF: https://github.com/llvm/llvm-project/commit/80dec2ecfffe30f86ecfeec8f553b16bb992c48b.diff
LOG: [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
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/AST/DeclCXX.cpp
clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a02bc0a2f691..17c1dac2e82a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -186,6 +186,8 @@ Bug Fixes
- Clang now checks ODR violations when merging concepts from
diff erent 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 6fc9a86bc3cf..c307cbe02ecf 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -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();
diff --git a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
index 25a40ef49401..73916fd3027e 100644
--- a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -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;
+};
+}
More information about the cfe-commits
mailing list