diff options
author | Jonathan Coe <jbcoe@me.com> | 2017-10-16 23:43:02 +0000 |
---|---|---|
committer | Jonathan Coe <jbcoe@me.com> | 2017-10-16 23:43:02 +0000 |
commit | 11e6fda273d7519bacf13475a98ecba6c41968b1 (patch) | |
tree | 8f1a2e87ee8240814c130acf831aeea60c7725c5 /bindings | |
parent | 551dc900ed276189569f3d814a3a5c540bab2fc6 (diff) | |
download | clang-11e6fda273d7519bacf13475a98ecba6c41968b1.tar.gz |
[libclang] Visit attributes for function and class templates
Summary: Previously, `VisitAttributes` was not called for function and class templates and thus their attributes were not accessible using libclang.
Reviewers: bkramer, arphaman, rsmith, jbcoe
Reviewed By: jbcoe
Subscribers: cfe-commits
Tags: #clang
Patch by jklaehn (Johann Klähn)
Differential Revision: https://reviews.llvm.org/D36955
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/python/tests/cindex/test_cursor.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py index e7c40c771e..4dd42fc84b 100644 --- a/bindings/python/tests/cindex/test_cursor.py +++ b/bindings/python/tests/cindex/test_cursor.py @@ -377,6 +377,26 @@ def test_annotation_attribute(): else: assert False, "Couldn't find annotation" +def test_annotation_template(): + annotation = '__attribute__ ((annotate("annotation")))' + for source, kind in [ + ('int foo (T value) %s;', CursorKind.FUNCTION_TEMPLATE), + ('class %s foo {};', CursorKind.CLASS_TEMPLATE), + ]: + source = 'template<typename T> ' + (source % annotation) + tu = get_tu(source, lang="cpp") + + foo = get_cursor(tu, 'foo') + assert foo is not None + assert foo.kind == kind + + for c in foo.get_children(): + if c.kind == CursorKind.ANNOTATE_ATTR: + assert c.displayname == "annotation" + break + else: + assert False, "Couldn't find annotation for {}".format(kind) + def test_result_type(): tu = get_tu('int foo();') foo = get_cursor(tu, 'foo') |