[clang.py] Implement Cursor.result_type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156752 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 0053796..d048fb6 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1024,6 +1024,14 @@
return self._type
@property
+ def result_type(self):
+ """Retrieve the Type of the result for this Cursor."""
+ if not hasattr(self, '_result_type'):
+ self._result_type = Type_get_result(self.type)
+
+ return self._result_type
+
+ @property
def underlying_typedef_type(self):
"""Return the underlying type of a typedef declaration.
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
index eda74f0..206d9c8 100644
--- a/bindings/python/tests/cindex/test_cursor.py
+++ b/bindings/python/tests/cindex/test_cursor.py
@@ -172,3 +172,11 @@
break
else:
assert False, "Couldn't find annotation"
+
+def test_result_type():
+ tu = get_tu('int foo();')
+ foo = get_cursor(tu, 'foo')
+
+ assert foo is not None
+ t = foo.result_type
+ assert t.kind == TypeKind.INT