Index: clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp =================================================================== --- clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp +++ clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp @@ -58,7 +58,10 @@ this); const auto IsBadReturnStatement = returnStmt(unless(has(ignoringParenImpCasts( - unaryOperator(hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())))))); + anyOf(unaryOperator(hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())), + cxxOperatorCallExpr(argumentCountIs(1), + callee(unresolvedLookupExpr()), + hasArgument(0, cxxThisExpr()))))))); const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType); Finder->addMatcher(returnStmt(IsBadReturnStatement, forFunction(IsGoodAssign)) 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 @@ -87,3 +87,21 @@ return n; } }; + +enum E { e }; +E operator*(E, E); + +template +struct UnresolvedOperator { + UnresolvedOperator &operator=(const UnresolvedOperator &) { return *this; } +}; + +UnresolvedOperator UnresolvedOperatorInt; + +template +struct Template { + Template &operator=(const Template &) { return this; } + // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: operator=() should always return '*this' +}; + +Template TemplateInt;