diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2015-04-13 16:55:04 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2015-04-13 16:55:04 +0000 |
commit | 2bff5161c430e88a0e6972eba57f2ebbd6ef8678 (patch) | |
tree | 65dcc3e45d2f0e32ad6ae77b8f64ab7670c7f0b3 /clang/bindings/python/tests | |
parent | e73300b925df8002351d51bf9da099abea9ca501 (diff) | |
download | bcm5719-llvm-2bff5161c430e88a0e6972eba57f2ebbd6ef8678.tar.gz bcm5719-llvm-2bff5161c430e88a0e6972eba57f2ebbd6ef8678.zip |
[libclang] Add functions to get information about fields.
Patch by Loïc Jaquemet!
llvm-svn: 234762
Diffstat (limited to 'clang/bindings/python/tests')
-rw-r--r-- | clang/bindings/python/tests/cindex/test_type.py | 21 |
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 |