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();
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();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits