[clang-tools-extra] r330719 - [clang-tidy] Fix PR35468
Gabor Horvath via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 24 07:45:58 PDT 2018
Author: xazax
Date: Tue Apr 24 07:45:58 2018
New Revision: 330719
URL: http://llvm.org/viewvc/llvm-project?rev=330719&view=rev
Log:
[clang-tidy] Fix PR35468
Differential Revision: https://reviews.llvm.org/D46003
Added:
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp?rev=330719&r1=330718&r2=330719&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp Tue Apr 24 07:45:58 2018
@@ -24,9 +24,9 @@ void UnconventionalAssignOperatorCheck::
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")),
Added: clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp?rev=330719&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp Tue Apr 24 07:45:58 2018
@@ -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;
+ }
+};
More information about the cfe-commits
mailing list