clang-tidy: [misc-use-override] Correctly handle defaulted destructors.

Also, minor implementation and test fixes.

llvm-svn: 211345
This commit is contained in:
Daniel Jasper 2014-06-20 09:12:46 +00:00
parent b3b0b8034c
commit 024ebf4a65
2 changed files with 11 additions and 7 deletions

View File

@ -77,10 +77,9 @@ void UseOverride::check(const MatchFinder::MatchResult &Result) {
? "Prefer using 'override' or 'final' instead of 'virtual'"
: "Use exactly one of 'virtual', 'override' and 'final'");
CharSourceRange FileRange =
Lexer::makeFileCharRange(CharSourceRange::getTokenRange(
Method->getLocStart(), Method->getLocEnd()),
Sources, Result.Context->getLangOpts());
CharSourceRange FileRange = Lexer::makeFileCharRange(
CharSourceRange::getTokenRange(Method->getSourceRange()), Sources,
Result.Context->getLangOpts());
if (!FileRange.isValid())
return;
@ -106,9 +105,8 @@ void UseOverride::check(const MatchFinder::MatchResult &Result) {
}
if (InsertLoc.isInvalid() && Method->doesThisDeclarationHaveABody() &&
Method->getBody()) {
Method->getBody() && !Method->isDefaulted())
InsertLoc = Method->getBody()->getLocStart();
}
if (!InsertLoc.isValid()) {
if (Tokens.size() > 2 && GetText(Tokens.back(), Sources) == "0" &&

View File

@ -67,6 +67,12 @@ void SimpleCases::i() {}
SimpleCases::~SimpleCases() {}
// CHECK: {{^SimpleCases::~SimpleCases\(\) {}}}
struct DefaultedDestructor : public Base {
DefaultedDestructor() {}
virtual ~DefaultedDestructor() = default;
// CHECK: {{^ ~DefaultedDestructor\(\) override = default;}}
};
struct FinalSpecified : public Base {
public:
virtual ~FinalSpecified() final;
@ -161,4 +167,4 @@ struct MembersOfSpecializations : public Base {
// CHECK: {{^ void a\(\) override;}}
};
template <> void MembersOfSpecializations<3>::a() {}
void f() { D<3>().a(); };
void f() { MembersOfSpecializations<3>().a(); };