[PATCH] Request for approval to commit: [libclang/python]: Add support for decayed type
Anders Waldenborg
anders at 0x63.nu
Thu Sep 12 05:12:05 PDT 2013
http://llvm-reviews.chandlerc.com/D1658
Files:
bindings/python/clang/cindex.py
bindings/python/tests/cindex/test_type.py
Index: bindings/python/clang/cindex.py
===================================================================
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1486,6 +1486,7 @@
TypeKind.INCOMPLETEARRAY = TypeKind(114)
TypeKind.VARIABLEARRAY = TypeKind(115)
TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
+TypeKind.DECAYED = TypeKind(117)
class Type(Structure):
"""
@@ -1661,6 +1662,18 @@
"""
return conf.lib.clang_getArraySize(self)
+ def get_decayed_original_type(self):
+ """
+ Retrieve the original type of a decayed type.
+ """
+ return conf.lib.clang_getDecayedOriginalType(self)
+
+ def get_decayed_decayed_type(self):
+ """
+ Retrieve the decayed type of a decayed type.
+ """
+ return conf.lib.clang_getDecayedDecayedType(self)
+
def get_align(self):
"""
Retrieve the alignment of the record.
@@ -2693,6 +2706,16 @@
[Type],
c_longlong),
+ ("clang_getDecayedOriginalType",
+ [Type],
+ Type,
+ Type.from_result),
+
+ ("clang_getDecayedDecayedType",
+ [Type],
+ Type,
+ Type.from_result),
+
("clang_getFieldDeclBitWidth",
[Cursor],
c_int),
Index: bindings/python/tests/cindex/test_type.py
===================================================================
--- bindings/python/tests/cindex/test_type.py
+++ bindings/python/tests/cindex/test_type.py
@@ -369,3 +369,14 @@
assert teststruct.type.get_offset("bar") == bar
+def test_decay():
+ """Ensure decayed types are exposed"""
+
+ tu = get_tu("void foo(int a[]);")
+ foo = get_cursor(tu, 'foo')
+ a = foo.type.argument_types()[0]
+
+ assert a.kind == TypeKind.DECAYED
+ assert a.get_decayed_original_type().kind == TypeKind.INCOMPLETEARRAY
+ assert a.get_decayed_decayed_type().kind == TypeKind.POINTER
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1658.1.patch
Type: text/x-patch
Size: 1868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130912/09f662c9/attachment.bin>
More information about the cfe-commits
mailing list