summaryrefslogtreecommitdiffstats
path: root/bindings/python
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
committerdim <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
commit3176e97f130184ece0e1a21352c8124cc83ff24a (patch)
tree0a5b74c0b9ca73aded34df95c91fcaf3815230d8 /bindings/python
parent1e9b8d38881c3213d1e67b0c47ab9b2c00721a5c (diff)
downloadFreeBSD-src-3176e97f130184ece0e1a21352c8124cc83ff24a.zip
FreeBSD-src-3176e97f130184ece0e1a21352c8124cc83ff24a.tar.gz
Vendor import of clang trunk r256633:
https://llvm.org/svn/llvm-project/cfe/trunk@256633
Diffstat (limited to 'bindings/python')
-rw-r--r--bindings/python/clang/cindex.py41
-rw-r--r--bindings/python/tests/cindex/test_cursor.py60
-rw-r--r--bindings/python/tests/cindex/test_cursor_kind.py1
-rw-r--r--bindings/python/tests/cindex/test_type.py4
4 files changed, 103 insertions, 3 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index f5caca8..e4b3876 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1100,6 +1100,11 @@ CursorKind.CUDAGLOBAL_ATTR = CursorKind(414)
CursorKind.CUDAHOST_ATTR = CursorKind(415)
CursorKind.CUDASHARED_ATTR = CursorKind(416)
+CursorKind.VISIBILITY_ATTR = CursorKind(417)
+
+CursorKind.DLLEXPORT_ATTR = CursorKind(418)
+CursorKind.DLLIMPORT_ATTR = CursorKind(419)
+
###
# Preprocessing
CursorKind.PREPROCESSING_DIRECTIVE = CursorKind(500)
@@ -1112,7 +1117,8 @@ CursorKind.INCLUSION_DIRECTIVE = CursorKind(503)
# A module import declaration.
CursorKind.MODULE_IMPORT_DECL = CursorKind(600)
-
+# A type alias template declaration
+CursorKind.TYPE_ALIAS_TEMPLATE_DECL = CursorKind(601)
### Template Argument Kinds ###
class TemplateArgumentKind(BaseEnumeration):
@@ -1162,12 +1168,36 @@ class Cursor(Structure):
"""
return conf.lib.clang_isCursorDefinition(self)
+ def is_const_method(self):
+ """Returns True if the cursor refers to a C++ member function or member
+ function template that is declared 'const'.
+ """
+ return conf.lib.clang_CXXMethod_isConst(self)
+
+ def is_mutable_field(self):
+ """Returns True if the cursor refers to a C++ field that is declared
+ 'mutable'.
+ """
+ return conf.lib.clang_CXXField_isMutable(self)
+
+ def is_pure_virtual_method(self):
+ """Returns True if the cursor refers to a C++ member function or member
+ function template that is declared pure virtual.
+ """
+ return conf.lib.clang_CXXMethod_isPureVirtual(self)
+
def is_static_method(self):
"""Returns True if the cursor refers to a C++ member function or member
function template that is declared 'static'.
"""
return conf.lib.clang_CXXMethod_isStatic(self)
+ def is_virtual_method(self):
+ """Returns True if the cursor refers to a C++ member function or member
+ function template that is declared 'virtual'.
+ """
+ return conf.lib.clang_CXXMethod_isVirtual(self)
+
def get_definition(self):
"""
If the cursor is a reference to a declaration or a declaration of
@@ -1673,6 +1703,7 @@ TypeKind.INCOMPLETEARRAY = TypeKind(114)
TypeKind.VARIABLEARRAY = TypeKind(115)
TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
TypeKind.MEMBERPOINTER = TypeKind(117)
+TypeKind.AUTO = TypeKind(118)
class RefQualifierKind(BaseEnumeration):
"""Describes a specific ref-qualifier of a type."""
@@ -2877,6 +2908,14 @@ functionList = [
[Index, c_char_p],
c_object_p),
+ ("clang_CXXField_isMutable",
+ [Cursor],
+ bool),
+
+ ("clang_CXXMethod_isConst",
+ [Cursor],
+ bool),
+
("clang_CXXMethod_isPureVirtual",
[Cursor],
bool),
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
index a5224aa..c5ea505 100644
--- a/bindings/python/tests/cindex/test_cursor.py
+++ b/bindings/python/tests/cindex/test_cursor.py
@@ -97,6 +97,36 @@ def test_canonical():
assert len(cursors) == 3
assert cursors[1].canonical == cursors[2].canonical
+def test_is_const_method():
+ """Ensure Cursor.is_const_method works."""
+ source = 'class X { void foo() const; void bar(); };'
+ tu = get_tu(source, lang='cpp')
+
+ cls = get_cursor(tu, 'X')
+ foo = get_cursor(tu, 'foo')
+ bar = get_cursor(tu, 'bar')
+ assert cls is not None
+ assert foo is not None
+ assert bar is not None
+
+ assert foo.is_const_method()
+ assert not bar.is_const_method()
+
+def test_is_mutable_field():
+ """Ensure Cursor.is_mutable_field works."""
+ source = 'class X { int x_; mutable int y_; };'
+ tu = get_tu(source, lang='cpp')
+
+ cls = get_cursor(tu, 'X')
+ x_ = get_cursor(tu, 'x_')
+ y_ = get_cursor(tu, 'y_')
+ assert cls is not None
+ assert x_ is not None
+ assert y_ is not None
+
+ assert not x_.is_mutable_field()
+ assert y_.is_mutable_field()
+
def test_is_static_method():
"""Ensure Cursor.is_static_method works."""
@@ -113,6 +143,36 @@ def test_is_static_method():
assert foo.is_static_method()
assert not bar.is_static_method()
+def test_is_pure_virtual_method():
+ """Ensure Cursor.is_pure_virtual_method works."""
+ source = 'class X { virtual void foo() = 0; virtual void bar(); };'
+ tu = get_tu(source, lang='cpp')
+
+ cls = get_cursor(tu, 'X')
+ foo = get_cursor(tu, 'foo')
+ bar = get_cursor(tu, 'bar')
+ assert cls is not None
+ assert foo is not None
+ assert bar is not None
+
+ assert foo.is_pure_virtual_method()
+ assert not bar.is_pure_virtual_method()
+
+def test_is_virtual_method():
+ """Ensure Cursor.is_virtual_method works."""
+ source = 'class X { virtual void foo(); void bar(); };'
+ tu = get_tu(source, lang='cpp')
+
+ cls = get_cursor(tu, 'X')
+ foo = get_cursor(tu, 'foo')
+ bar = get_cursor(tu, 'bar')
+ assert cls is not None
+ assert foo is not None
+ assert bar is not None
+
+ assert foo.is_virtual_method()
+ assert not bar.is_virtual_method()
+
def test_underlying_type():
tu = get_tu('typedef int foo;')
typedef = get_cursor(tu, 'foo')
diff --git a/bindings/python/tests/cindex/test_cursor_kind.py b/bindings/python/tests/cindex/test_cursor_kind.py
index 8cabc51..5bac289 100644
--- a/bindings/python/tests/cindex/test_cursor_kind.py
+++ b/bindings/python/tests/cindex/test_cursor_kind.py
@@ -13,6 +13,7 @@ def test_get_all_kinds():
assert CursorKind.OBJ_SELF_EXPR in kinds
assert CursorKind.MS_ASM_STMT in kinds
assert CursorKind.MODULE_IMPORT_DECL in kinds
+ assert CursorKind.TYPE_ALIAS_TEMPLATE_DECL in kinds
def test_kind_groups():
"""Check that every kind classifies to exactly one group."""
diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py
index f3dadf9..f218433 100644
--- a/bindings/python/tests/cindex/test_type.py
+++ b/bindings/python/tests/cindex/test_type.py
@@ -134,7 +134,7 @@ def test_equal():
def test_type_spelling():
"""Ensure Type.spelling works."""
- tu = get_tu('int c[5]; int i[]; int x; int v[x];')
+ tu = get_tu('int c[5]; void f(int i[]); int x; int v[x];')
c = get_cursor(tu, 'c')
i = get_cursor(tu, 'i')
x = get_cursor(tu, 'x')
@@ -253,7 +253,7 @@ void bar(int a, int b);
def test_element_type():
"""Ensure Type.element_type works."""
- tu = get_tu('int c[5]; int i[]; int x; int v[x];')
+ tu = get_tu('int c[5]; void f(int i[]); int x; int v[x];')
c = get_cursor(tu, 'c')
i = get_cursor(tu, 'i')
v = get_cursor(tu, 'v')
OpenPOWER on IntegriCloud