aboutsummaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:22 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:22 +0000
commit1b08b196ac845675036ac78f3ac927d0a37f707c (patch)
tree1fbd923674e903831dc097fdb4fdfd64dd6e47b1 /bindings
parent551c698530debaae81139c7c76a29fb762793362 (diff)
downloadsrc-1b08b196ac845675036ac78f3ac927d0a37f707c.tar.gz
src-1b08b196ac845675036ac78f3ac927d0a37f707c.zip
Vendor import of clang trunk r305145:vendor/clang/clang-trunk-r305145
Notes
Notes: svn path=/vendor/clang/dist/; revision=319782 svn path=/vendor/clang/clang-trunk-r305145/; revision=319783; tag=vendor/clang/clang-trunk-r305145
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/clang/cindex.py11
-rw-r--r--bindings/python/tests/cindex/test_type.py17
2 files changed, 28 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 2c50d2722dec..8440b0aabe08 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -2162,6 +2162,12 @@ class Type(Structure):
return conf.lib.clang_isFunctionTypeVariadic(self)
+ def get_address_space(self):
+ return conf.lib.clang_getAddressSpace(self)
+
+ def get_typedef_name(self):
+ return conf.lib.clang_getTypedefName(self)
+
def is_pod(self):
"""Determine whether this Type represents plain old data (POD)."""
return conf.lib.clang_isPODType(self)
@@ -3665,6 +3671,11 @@ functionList = [
Type,
Type.from_result),
+ ("clang_getTypedefName",
+ [Type],
+ _CXString,
+ _CXString.from_result),
+
("clang_getTypeKindSpelling",
[c_uint],
_CXString,
diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py
index f2184338be4b..6ee0773828ec 100644
--- a/bindings/python/tests/cindex/test_type.py
+++ b/bindings/python/tests/cindex/test_type.py
@@ -37,37 +37,44 @@ def test_a_struct():
assert not fields[0].type.is_const_qualified()
assert fields[0].type.kind == TypeKind.INT
assert fields[0].type.get_canonical().kind == TypeKind.INT
+ assert fields[0].type.get_typedef_name() == ''
assert fields[1].spelling == 'b'
assert not fields[1].type.is_const_qualified()
assert fields[1].type.kind == TypeKind.TYPEDEF
assert fields[1].type.get_canonical().kind == TypeKind.INT
assert fields[1].type.get_declaration().spelling == 'I'
+ assert fields[1].type.get_typedef_name() == 'I'
assert fields[2].spelling == 'c'
assert not fields[2].type.is_const_qualified()
assert fields[2].type.kind == TypeKind.LONG
assert fields[2].type.get_canonical().kind == TypeKind.LONG
+ assert fields[2].type.get_typedef_name() == ''
assert fields[3].spelling == 'd'
assert not fields[3].type.is_const_qualified()
assert fields[3].type.kind == TypeKind.ULONG
assert fields[3].type.get_canonical().kind == TypeKind.ULONG
+ assert fields[3].type.get_typedef_name() == ''
assert fields[4].spelling == 'e'
assert not fields[4].type.is_const_qualified()
assert fields[4].type.kind == TypeKind.LONG
assert fields[4].type.get_canonical().kind == TypeKind.LONG
+ assert fields[4].type.get_typedef_name() == ''
assert fields[5].spelling == 'f'
assert fields[5].type.is_const_qualified()
assert fields[5].type.kind == TypeKind.INT
assert fields[5].type.get_canonical().kind == TypeKind.INT
+ assert fields[5].type.get_typedef_name() == ''
assert fields[6].spelling == 'g'
assert not fields[6].type.is_const_qualified()
assert fields[6].type.kind == TypeKind.POINTER
assert fields[6].type.get_pointee().kind == TypeKind.INT
+ assert fields[6].type.get_typedef_name() == ''
assert fields[7].spelling == 'h'
assert not fields[7].type.is_const_qualified()
@@ -75,6 +82,7 @@ def test_a_struct():
assert fields[7].type.get_pointee().kind == TypeKind.POINTER
assert fields[7].type.get_pointee().get_pointee().kind == TypeKind.POINTER
assert fields[7].type.get_pointee().get_pointee().get_pointee().kind == TypeKind.INT
+ assert fields[7].type.get_typedef_name() == ''
def test_references():
"""Ensure that a Type maintains a reference to a TranslationUnit."""
@@ -404,3 +412,12 @@ def test_decay():
assert a.kind == TypeKind.INCOMPLETEARRAY
assert a.element_type.kind == TypeKind.INT
assert a.get_canonical().kind == TypeKind.INCOMPLETEARRAY
+
+def test_addrspace():
+ """Ensure the address space can be queried"""
+ tu = get_tu('__attribute__((address_space(2))) int testInteger = 3;', 'c')
+
+ testInteger = get_cursor(tu, 'testInteger')
+
+ assert testInteger is not None, "Could not find testInteger."
+ assert testInteger.type.get_address_space() == 2