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 #638 from abbeyj/template-method-ref
Browse files Browse the repository at this point in the history
Reduce the range covered by references to template member functions.
  • Loading branch information
erikrose committed Feb 10, 2017
2 parents 6036f54 + d6474a8 commit bc18279
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dxr/plugins/clang/dxr-index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ class IndexConsumer : public ASTConsumer,
printReference(kindForDecl(e->getMemberDecl()),
e->getMemberDecl(),
e->getExprLoc(),
e->getSourceRange().getEnd());
e->getMemberNameInfo().getEndLoc());
return true;
}

Expand Down
37 changes: 37 additions & 0 deletions dxr/plugins/clang/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,43 @@ def test_function_ref(self):
[('Foo&lt;int&gt;().<b>bar</b>();', 16)])


class TemplateMemberReferenceTests(CSingleFileTestCase):
"""Tests for finding out where template member functions of a class are referenced or declared"""

source = r"""
class Foo
{
public:
template <typename T>
void bar();
};
template <typename T>
void Foo::bar()
{
}
void baz()
{
Foo().bar<int>();
}
""" + MINIMAL_MAIN

def test_function_decl(self):
"""Try searching for function declaration."""
self.found_line_eq('+function-decl:Foo::bar()', 'void <b>bar</b>();')

def test_function(self):
"""Try searching for function definition."""
self.found_lines_eq('+function:Foo::bar()',
[('void Foo::<b>bar</b>()', 10)])

def test_function_ref(self):
"""Try searching for function references."""
self.found_lines_eq('+function-ref:Foo::bar()',
[('Foo().<b>bar</b>&lt;int&gt;();', 16)])


class ConstTests(CSingleFileTestCase):
source = """
class ConstOverload
Expand Down

0 comments on commit bc18279

Please sign in to comment.