Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #497 from kleintom/virtual_overrides
Browse files Browse the repository at this point in the history
Get the clang plugin to recognize pure virtuals for overrides/overriddens. Fixes bug 1226893.
  • Loading branch information
erikrose committed Dec 16, 2015
2 parents d8b8caa + b7d0ff7 commit 4085323
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 13 additions & 5 deletions dxr/plugins/clang/dxr-index.cpp
Expand Up @@ -490,11 +490,19 @@ class IndexConsumer : public ASTConsumer,
// What do we override?
CXXMethodDecl::method_iterator iter = methodDecl->begin_overridden_methods();
if (iter) {
const FunctionDecl *overriddenDef;
if ((*iter)->isDefined(overriddenDef)) {
recordValue("overriddenname", overriddenDef->getNameAsString());
recordValue("overriddenqualname", getQualifiedName(*overriddenDef));
recordValue("overriddenloc", locationToString(overriddenDef->getLocStart())); // Finds the right line but the wrong columns. We ignore everything but the file path.
const FunctionDecl *overriddenDecl = nullptr;
// Get the overridden definition if it exists...
(*iter)->isDefined(overriddenDecl);
// Otherwise get the pure virtual declaration if that exists.
if (!overriddenDecl && (*iter)->isPure()) {
overriddenDecl = *iter;
}
if (overriddenDecl) {
recordValue("overriddenname", overriddenDecl->getNameAsString());
recordValue("overriddenqualname", getQualifiedName(*overriddenDecl));
// getLocStart() finds the right line but the wrong columns. We
// ignore everything but the file path.
recordValue("overriddenloc", locationToString(overriddenDecl->getLocStart()));
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions dxr/plugins/clang/tests/test_menus/test_menus.py
Expand Up @@ -187,10 +187,6 @@ def test_override_ref(self):
{'html': 'Find overrides',
'href': '/code/search?q=%2Boverrides%3ABaseClass%3A%3AvirtualFunc%28%29'})

# We don't yet recognize pure virtual functions as something that gets
# overridden - activate the next two tests when that gets fixed.

@nose.tools.raises(AssertionError) # remove this line when fixed
def test_override_pure_overrides(self):
"""Make sure pure virtual functions that have an override are
recognized."""
Expand All @@ -199,7 +195,6 @@ def test_override_pure_overrides(self):
{'html': 'Find overrides',
'href': '/code/search?q=%2Boverrides%3ABaseClass%3A%3ApVirtualFunc%28%29'})

@nose.tools.raises(AssertionError) # remove this line when fixed
def test_override_pure_overridden(self):
"""Make sure overrides of a pure virtual function are recognized."""
menu_on(self.source_page('extern.c'),
Expand Down

0 comments on commit 4085323

Please sign in to comment.