[clang-tools-extra] r211345 - clang-tidy: [misc-use-override] Correctly handle defaulted destructors.
Daniel Jasper
djasper at google.com
Fri Jun 20 02:12:51 PDT 2014
Author: djasper
Date: Fri Jun 20 04:12:46 2014
New Revision: 211345
URL: http://llvm.org/viewvc/llvm-project?rev=211345&view=rev
Log:
clang-tidy: [misc-use-override] Correctly handle defaulted destructors.
Also, minor implementation and test fixes.
Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp
clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp?rev=211345&r1=211344&r2=211345&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp Fri Jun 20 04:12:46 2014
@@ -77,10 +77,9 @@ void UseOverride::check(const MatchFinde
? "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 MatchFinde
}
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" &&
Modified: clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp?rev=211345&r1=211344&r2=211345&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp Fri Jun 20 04:12:46 2014
@@ -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
// CHECK: {{^ void a\(\) override;}}
};
template <> void MembersOfSpecializations<3>::a() {}
-void f() { D<3>().a(); };
+void f() { MembersOfSpecializations<3>().a(); };
More information about the cfe-commits
mailing list