[PATCH] D46003: [clang-tidy] Fix PR35468

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 24 07:49:32 PDT 2018


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;
+  }
+};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46003.143743.patch
Type: text/x-patch
Size: 1618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180424/459cf9ff/attachment.bin>


More information about the cfe-commits mailing list