]> granicus.if.org Git - clang/commitdiff
[clang.py] Implement Cursor.result_type
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 14 May 2012 03:53:29 +0000 (03:53 +0000)
committerGregory Szorc <gregory.szorc@gmail.com>
Mon, 14 May 2012 03:53:29 +0000 (03:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156752 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/python/clang/cindex.py
bindings/python/tests/cindex/test_cursor.py

index 0053796462a7cb66fb24c30ca0b40e09ad09234d..d048fb60c4ed8c0f92376bb6542d10e8d1a14f8a 100644 (file)
@@ -1023,6 +1023,14 @@ class Cursor(Structure):
             self._type = Cursor_type(self)
         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.
index eda74f0e2450f38b58a603391dd68329e3d50d0a..206d9c8521007485319d6107b01c6b8c081e9790 100644 (file)
@@ -172,3 +172,11 @@ def test_annotation_attribute():
             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