summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python/tests
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2015-01-29 12:45:29 +0000
committerFrancois Pichet <pichet2000@gmail.com>2015-01-29 12:45:29 +0000
commitf3be1cc5a9d5d75665a3d3cff54d51a161608c59 (patch)
tree46912475ca949b759b5d1c72a19a102661f4b724 /clang/bindings/python/tests
parentfad390109502f97f25828a993fd3bc2500fa93f5 (diff)
downloadbcm5719-llvm-f3be1cc5a9d5d75665a3d3cff54d51a161608c59.tar.gz
bcm5719-llvm-f3be1cc5a9d5d75665a3d3cff54d51a161608c59.zip
libclang: Add three functions useful for dealing with anonymous fields:
clang_Cursor_getOffsetOfField clang_Cursor_isAnonymous clang_Type_visitFields Python: Add corresponding methods for dealing with anonymous fields. Patch by Loïc Jaquemet llvm-svn: 227432
Diffstat (limited to 'clang/bindings/python/tests')
-rw-r--r--clang/bindings/python/tests/cindex/test_type.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py
index a02c06fe5a1..f3dadf999bd 100644
--- a/clang/bindings/python/tests/cindex/test_type.py
+++ b/clang/bindings/python/tests/cindex/test_type.py
@@ -363,6 +363,7 @@ def test_offset():
"""Ensure Cursor.get_record_field_offset works in anonymous records"""
source="""
struct Test {
+ struct {int a;} typeanon;
struct {
int bariton;
union {
@@ -371,15 +372,23 @@ struct Test {
};
int bar;
};"""
- tries=[(['-target','i386-linux-gnu'],(4,16,0,32,64)),
- (['-target','nvptx64-unknown-unknown'],(8,24,0,32,64)),
- (['-target','i386-pc-win32'],(8,16,0,32,64)),
- (['-target','msp430-none-none'],(2,14,0,32,64))]
+ tries=[(['-target','i386-linux-gnu'],(4,16,0,32,64,96)),
+ (['-target','nvptx64-unknown-unknown'],(8,24,0,32,64,96)),
+ (['-target','i386-pc-win32'],(8,16,0,32,64,96)),
+ (['-target','msp430-none-none'],(2,14,0,32,64,96))]
for flags, values in tries:
- align,total,bariton,foo,bar = values
+ align,total,f1,bariton,foo,bar = values
tu = get_tu(source)
teststruct = get_cursor(tu, 'Test')
- fields = list(teststruct.get_children())
+ children = list(teststruct.get_children())
+ fields = list(teststruct.type.get_fields())
+ assert children[0].kind == CursorKind.STRUCT_DECL
+ assert children[0].spelling != "typeanon"
+ assert children[1].spelling == "typeanon"
+ assert fields[0].kind == CursorKind.FIELD_DECL
+ assert fields[1].kind == CursorKind.FIELD_DECL
+ assert fields[1].is_anonymous()
+ assert teststruct.type.get_offset("typeanon") == f1
assert teststruct.type.get_offset("bariton") == bariton
assert teststruct.type.get_offset("foo") == foo
assert teststruct.type.get_offset("bar") == bar
OpenPOWER on IntegriCloud