diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-29 17:22:53 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-29 17:22:53 +0000 |
commit | 4779beea00d6c131705d6fbbc72d907433049e90 (patch) | |
tree | fad31e06ffc27fde3f79abae21956563dc73941c /bindings | |
parent | 07119f2310c40b689659642eb80f83cba0b5b1d2 (diff) | |
download | clang-4779beea00d6c131705d6fbbc72d907433049e90.tar.gz |
This reverts commit r227432, r227438 and r227448.
It should bring the bots back.
Original messagses:
r227448:
Remove unnecessary default.
r227438:
Fix Index/print-type.cpp test following r227432.
r227432:
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/python/clang/cindex.py | 40 | ||||
-rw-r--r-- | bindings/python/tests/cindex/test_type.py | 21 |
2 files changed, 6 insertions, 55 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index f5caca8572..5792effea5 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1476,18 +1476,6 @@ class Cursor(Structure): """ return TokenGroup.get_tokens(self._tu, self.extent) - def get_field_offsetof(self): - """Returns the offsetof the FIELD_DECL pointed by this Cursor.""" - return conf.lib.clang_Cursor_getOffsetOfField(self) - - def is_anonymous(self): - """ - Check if the record is anonymous. - """ - if self.kind == CursorKind.FIELD_DECL: - return self.type.get_declaration().is_anonymous() - return conf.lib.clang_Cursor_isAnonymous(self) - def is_bitfield(self): """ Check if the field is a bitfield. @@ -1896,21 +1884,6 @@ class Type(Structure): return RefQualifierKind.from_id( conf.lib.clang_Type_getCXXRefQualifier(self)) - def get_fields(self): - """Return an iterator for accessing the fields of this type.""" - - def visitor(field, children): - assert field != conf.lib.clang_getNullCursor() - - # Create reference to TU so it isn't GC'd before Cursor. - field._tu = self._tu - fields.append(field) - return 1 # continue - fields = [] - conf.lib.clang_Type_visitFields(self, - callbacks['fields_visit'](visitor), fields) - return iter(fields) - @property def spelling(self): """Retrieve the spelling of this Type.""" @@ -2807,7 +2780,6 @@ class Token(Structure): callbacks['translation_unit_includes'] = CFUNCTYPE(None, c_object_p, POINTER(SourceLocation), c_uint, py_object) callbacks['cursor_visit'] = CFUNCTYPE(c_int, Cursor, Cursor, py_object) -callbacks['fields_visit'] = CFUNCTYPE(c_int, Cursor, py_object) # Functions strictly alphabetical order. functionList = [ @@ -3395,10 +3367,6 @@ functionList = [ [Cursor, c_uint], c_ulonglong), - ("clang_Cursor_isAnonymous", - [Cursor], - bool), - ("clang_Cursor_isBitField", [Cursor], bool), @@ -3413,10 +3381,6 @@ functionList = [ _CXString, _CXString.from_result), - ("clang_Cursor_getOffsetOfField", - [Cursor], - c_longlong), - ("clang_Type_getAlignOf", [Type], c_longlong), @@ -3437,10 +3401,6 @@ functionList = [ ("clang_Type_getCXXRefQualifier", [Type], c_uint), - - ("clang_Type_visitFields", - [Type, callbacks['fields_visit'], py_object], - c_uint), ] class LibclangError(Exception): diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py index f3dadf999b..a02c06fe5a 100644 --- a/bindings/python/tests/cindex/test_type.py +++ b/bindings/python/tests/cindex/test_type.py @@ -363,7 +363,6 @@ def test_offset(): """Ensure Cursor.get_record_field_offset works in anonymous records""" source=""" struct Test { - struct {int a;} typeanon; struct { int bariton; union { @@ -372,23 +371,15 @@ struct Test { }; int bar; };""" - 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))] + 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))] for flags, values in tries: - align,total,f1,bariton,foo,bar = values + align,total,bariton,foo,bar = values tu = get_tu(source) teststruct = get_cursor(tu, 'Test') - 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 + fields = list(teststruct.get_children()) assert teststruct.type.get_offset("bariton") == bariton assert teststruct.type.get_offset("foo") == foo assert teststruct.type.get_offset("bar") == bar |