[clang-tools-extra] r210031 - clang-tidy: Extend the use-override check to understand 'final'.
Daniel Jasper
djasper at google.com
Mon Jun 2 08:22:22 PDT 2014
Author: djasper
Date: Mon Jun 2 10:22:22 2014
New Revision: 210031
URL: http://llvm.org/viewvc/llvm-project?rev=210031&view=rev
Log:
clang-tidy: Extend the use-override check to understand 'final'.
Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp
clang-tools-extra/trunk/test/clang-tidy/use-override.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=210031&r1=210030&r2=210031&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverride.cpp Mon Jun 2 10:22:22 2014
@@ -65,8 +65,9 @@ void UseOverride::check(const MatchFinde
!Method->isVirtualAsWritten())
return; // Nothing to do.
- DiagnosticBuilder Diag = diag(Method->getLocation(),
- "Prefer using 'override' instead of 'virtual'");
+ DiagnosticBuilder Diag =
+ diag(Method->getLocation(),
+ "Prefer using 'override' or 'final' instead of 'virtual'");
CharSourceRange FileRange =
Lexer::makeFileCharRange(CharSourceRange::getTokenRange(
@@ -83,7 +84,8 @@ void UseOverride::check(const MatchFinde
Result.Context->getLangOpts());
// Add 'override' on inline declarations that don't already have it.
- if (Method->getAttr<clang::OverrideAttr>() == nullptr) {
+ if (Method->getAttr<clang::OverrideAttr>() == nullptr &&
+ Method->getAttr<clang::FinalAttr>() == nullptr) {
SourceLocation InsertLoc;
StringRef ReplacementText = "override ";
Modified: clang-tools-extra/trunk/test/clang-tidy/use-override.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/use-override.cpp?rev=210031&r1=210030&r2=210031&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/use-override.cpp Mon Jun 2 10:22:22 2014
@@ -62,6 +62,25 @@ void SimpleCases::i() {}
SimpleCases::~SimpleCases() {}
// CHECK: {{^SimpleCases::~SimpleCases\(\) {}}}
+struct FinalSpecified : public Base {
+public:
+ virtual ~FinalSpecified() final;
+ // CHECK: {{^ ~FinalSpecified\(\) final;}}
+
+ void b() final;
+ // CHECK: {{^ void b\(\) final;}}
+ virtual void d() final;
+ // CHECK: {{^ void d\(\) final;}}
+
+ virtual void e() final = 0;
+ // CHECK: {{^ void e\(\) final = 0;}}
+
+ virtual void j() const final;
+ // CHECK: {{^ void j\(\) const final;}}
+ virtual bool l() final MUST_USE_RESULT;
+ // CHECK: {{^ bool l\(\) final MUST_USE_RESULT;}}
+};
+
struct InlineDefinitions : public Base {
public:
virtual ~InlineDefinitions() {}
More information about the cfe-commits
mailing list