[PATCH] D46003: [clang-tidy] Fix PR35468
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 24 04:54:36 PDT 2018
xazax.hun created this revision.
xazax.hun added a reviewer: alexfh.
Herald added subscribers: dkrupp, rnkovacs, baloghadamsoftware, whisperity.
Auto return type was not correctly considered by the Unconventional Assign Operator check.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D46003
Files:
clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
test/clang-tidy/misc-unconventional-assign-operator.cpp
Index: test/clang-tidy/misc-unconventional-assign-operator.cpp
===================================================================
--- test/clang-tidy/misc-unconventional-assign-operator.cpp
+++ test/clang-tidy/misc-unconventional-assign-operator.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++11 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++17 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
namespace std {
template <typename T>
@@ -25,6 +25,12 @@
AlsoGood& operator=(AlsoGood);
};
+struct PR35468 {
+ template<typename T> auto &operator=(const T &) {
+ return *this;
+ }
+};
+
struct BadReturnType {
void operator=(const BadReturnType&);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturnType&' [misc-unconventional-assign-operator]
Index: clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===================================================================
--- clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ 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")),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46003.143712.patch
Type: text/x-patch
Size: 1750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180424/ef7864d0/attachment.bin>
More information about the cfe-commits
mailing list