[clang-tidy] Fix PR35468

Differential Revision: https://reviews.llvm.org/D46003

llvm-svn: 330719
This commit is contained in:
Gabor Horvath 2018-04-24 14:45:58 +00:00
parent 497c70fff1
commit 2735166156
2 changed files with 15 additions and 3 deletions

View File

@ -24,9 +24,9 @@ void UnconventionalAssignOperatorCheck::registerMatchers(
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")),

View File

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