diff --git a/clang-tools-extra/clang-tidy/daedalean/AssignmentOperatorsCheck.cpp b/clang-tools-extra/clang-tidy/daedalean/AssignmentOperatorsCheck.cpp index 299b13c5df2f97..f9be4452e8d3a2 100644 --- a/clang-tools-extra/clang-tidy/daedalean/AssignmentOperatorsCheck.cpp +++ b/clang-tools-extra/clang-tidy/daedalean/AssignmentOperatorsCheck.cpp @@ -36,13 +36,25 @@ void AssignmentOperatorsCheck::check(const MatchFinder::MatchResult &Result) { } if (!MatchedDecl->hasUserDeclaredCopyAssignment()) { - diag(MatchedDecl->getBeginLoc(), + auto SourceLocation = MatchedDecl->getBeginLoc(); + + if (!MatchedDecl->bases().empty()) { + SourceLocation = MatchedDecl->bases_begin()->getBeginLoc(); + } + + diag(SourceLocation, "Non-abstract class %0 must implement copy-assignment operator") << MatchedDecl; } if (!MatchedDecl->hasUserDeclaredMoveAssignment()) { - diag(MatchedDecl->getBeginLoc(), + auto SourceLocation = MatchedDecl->getBeginLoc(); + + if (!MatchedDecl->bases().empty()) { + SourceLocation = MatchedDecl->bases_begin()->getBeginLoc(); + } + + diag(SourceLocation, "Non-abstract class %0 must implement move-assignment operator") << MatchedDecl; }