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 | 578ac7a2ec4a772f97d9cb566c95764ff3d41625 (patch) | |
tree | c431daa18e6558c1044c44141ecedb71ede65bc2 /clang/bindings | |
parent | 4e3d6160db325ce5ba18be99eda2c3555e58609a (diff) |
[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
llvm-svn: 315958
Diffstat (limited to 'clang/bindings')
-rw-r--r-- | clang/bindings/python/tests/cindex/test_cursor.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py index e7c40c771ef8..4dd42fc84bdd 100644 --- a/clang/bindings/python/tests/cindex/test_cursor.py +++ b/clang/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') |