summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python/tests
diff options
context:
space:
mode:
authorJonathan Coe <jbcoe@me.com>2017-10-16 23:46:02 +0000
committerJonathan Coe <jbcoe@me.com>2017-10-16 23:46:02 +0000
commit1fada3b90ac49a40685ba039552c167f33e251cb (patch)
tree9ff773f4669042b2c509d6acd7d1145ae36f94af /clang/bindings/python/tests
parent578ac7a2ec4a772f97d9cb566c95764ff3d41625 (diff)
downloadbcm5719-llvm-1fada3b90ac49a40685ba039552c167f33e251cb.tar.gz
bcm5719-llvm-1fada3b90ac49a40685ba039552c167f33e251cb.zip
[libclang] Add support for querying cursor availability
Summary: This patch allows checking the availability of cursors through libclang and clang.cindex (Python). This e.g. allows to check whether a C++ member function has been marked as deleted. Reviewers: arphaman, jbcoe Reviewed By: jbcoe Subscribers: cfe-commits Tags: #clang Patch by jklaehn (Johann Klähn) Differential Revision: https://reviews.llvm.org/D36973 llvm-svn: 315959
Diffstat (limited to 'clang/bindings/python/tests')
-rw-r--r--clang/bindings/python/tests/cindex/test_cursor.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py
index 4dd42fc84bd..8ff06951546 100644
--- a/clang/bindings/python/tests/cindex/test_cursor.py
+++ b/clang/bindings/python/tests/cindex/test_cursor.py
@@ -1,6 +1,7 @@
import ctypes
import gc
+from clang.cindex import AvailabilityKind
from clang.cindex import CursorKind
from clang.cindex import TemplateArgumentKind
from clang.cindex import TranslationUnit
@@ -405,6 +406,30 @@ def test_result_type():
t = foo.result_type
assert t.kind == TypeKind.INT
+def test_availability():
+ tu = get_tu('class A { A(A const&) = delete; };', lang='cpp')
+
+ # AvailabilityKind.AVAILABLE
+ cursor = get_cursor(tu, 'A')
+ assert cursor.kind == CursorKind.CLASS_DECL
+ assert cursor.availability == AvailabilityKind.AVAILABLE
+
+ # AvailabilityKind.NOT_AVAILABLE
+ cursors = get_cursors(tu, 'A')
+ for c in cursors:
+ if c.kind == CursorKind.CONSTRUCTOR:
+ assert c.availability == AvailabilityKind.NOT_AVAILABLE
+ break
+ else:
+ assert False, "Could not find cursor for deleted constructor"
+
+ # AvailabilityKind.DEPRECATED
+ tu = get_tu('void test() __attribute__((deprecated));', lang='cpp')
+ cursor = get_cursor(tu, 'test')
+ assert cursor.availability == AvailabilityKind.DEPRECATED
+
+ # AvailabilityKind.NOT_ACCESSIBLE is only used in the code completion results
+
def test_get_tokens():
"""Ensure we can map cursors back to tokens."""
tu = get_tu('int foo(int i);')
OpenPOWER on IntegriCloud