This revision was automatically updated to reflect the committed changes. Closed by commit rL330719: [clang-tidy] Fix PR35468 (authored by xazax, committed by ). Herald added subscribers: llvm-commits, klimek.
Changed prior to commit: https://reviews.llvm.org/D46003?vs=143712&id=143743#toc Repository: rL LLVM https://reviews.llvm.org/D46003 Files: clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp Index: clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp @@ -24,9 +24,9 @@ if (!getLangOpts().CPlusPlus) return; - const auto HasGoodReturnType = cxxMethodDecl(returns( - lValueReferenceType(pointee(unless(isConstQualified()), - hasDeclaration(equalsBoundNode("class")))))); + const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType( + pointee(unless(isConstQualified()), + anyOf(autoType(), hasDeclaration(equalsBoundNode("class"))))))); const auto IsSelf = qualType( anyOf(hasDeclaration(equalsBoundNode("class")), Index: clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp @@ -0,0 +1,12 @@ +// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++17 -fno-delayed-template-parsing + +struct BadModifier { + BadModifier& operator=(const BadModifier&) const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'const' +}; + +struct PR35468 { + template<typename T> auto &operator=(const T &) { + return *this; + } +};
Index: clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp @@ -24,9 +24,9 @@ if (!getLangOpts().CPlusPlus) return; - const auto HasGoodReturnType = cxxMethodDecl(returns( - lValueReferenceType(pointee(unless(isConstQualified()), - hasDeclaration(equalsBoundNode("class")))))); + const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType( + pointee(unless(isConstQualified()), + anyOf(autoType(), hasDeclaration(equalsBoundNode("class"))))))); const auto IsSelf = qualType( anyOf(hasDeclaration(equalsBoundNode("class")), Index: clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp @@ -0,0 +1,12 @@ +// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++17 -fno-delayed-template-parsing + +struct BadModifier { + BadModifier& operator=(const BadModifier&) const; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'const' +}; + +struct PR35468 { + template<typename T> auto &operator=(const T &) { + return *this; + } +};
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits