Skip to content

Commit

Permalink
Clang plugin: *Overriding* method must have "virtual" keyword.
Browse files Browse the repository at this point in the history
The overridden method is the one in the base class.
It's the overriding method that might be missing the "virtual" keyword.

BUG=none
TEST=none


Review URL: http://codereview.chromium.org/8465020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109473 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
hans@chromium.org committed Nov 10, 2011
1 parent c41b93b commit b4576f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/clang/plugins/FindBadConstructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class FindBadConstructsConsumer : public ChromeClassTester {
loc = method->getInnerLocStart();

if (method->isVirtual() && !method->isVirtualAsWritten())
emitWarning(loc, "Overridden method must have \"virtual\" keyword.");
emitWarning(loc, "Overriding method must have \"virtual\" keyword.");

// Virtual methods should not have inline definitions beyond "{}".
if (method->isVirtual() && method->hasBody() && method->hasInlineBody()) {
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/plugins/tests/virtual_methods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ In file included from virtual_methods.cpp:5:
./virtual_methods.h:17:36: warning: [chromium-style] virtual methods with non-empty bodies shouldn't be declared inline.
virtual bool ComplainAboutThis() { return true; }
^
./virtual_methods.h:23:3: warning: [chromium-style] Overridden method must have "virtual" keyword.
./virtual_methods.h:23:3: warning: [chromium-style] Overriding method must have "virtual" keyword.
void MethodHasNoArguments();
^
2 warnings generated.

0 comments on commit b4576f3

Please sign in to comment.