Skip to content

Commit

Permalink
daedalean-assignment-operators: report location of base if available
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier-varez committed Aug 11, 2022
1 parent 63f720f commit 8a86e23
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8a86e23

Please sign in to comment.