summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorJonathan Coe <jbcoe@me.com>2018-04-22 20:51:05 +0000
committerJonathan Coe <jbcoe@me.com>2018-04-22 20:51:05 +0000
commit33a33e52edd3135424687beae94eefb01e5d60f8 (patch)
treea9f8cf710463e0f2acd90aad25311d153445205f /bindings
parent67f6e8a2d2dd18a27940560167135c468570e67c (diff)
[python bindings] Fix Cursor.result_type for ObjC method declarations - Bug 36677
Summary: In cindex.py, Cursor.result_type called into the wrong libclang function, causing cursors for ObjC method declarations to return invalid result types. Fixes Bug 36677. Reviewers: jbcoe, rsmith Reviewed By: jbcoe Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D45671 Patch by kjteske (Kyle Teske). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/clang/cindex.py7
-rw-r--r--bindings/python/tests/cindex/test_cursor.py12
2 files changed, 18 insertions, 1 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 043b5fb37d..06fc79950e 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1644,7 +1644,7 @@ class Cursor(Structure):
def result_type(self):
"""Retrieve the Type of the result for this Cursor."""
if not hasattr(self, '_result_type'):
- self._result_type = conf.lib.clang_getResultType(self.type)
+ self._result_type = conf.lib.clang_getCursorResultType(self)
return self._result_type
@@ -3568,6 +3568,11 @@ functionList = [
[Cursor, c_uint, c_uint],
SourceRange),
+ ("clang_getCursorResultType",
+ [Cursor],
+ Type,
+ Type.from_result),
+
("clang_getCursorSemanticParent",
[Cursor],
Cursor,
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
index c2a4eb57d0..2575ffb8a5 100644
--- a/bindings/python/tests/cindex/test_cursor.py
+++ b/bindings/python/tests/cindex/test_cursor.py
@@ -429,6 +429,18 @@ class TestCursor(unittest.TestCase):
t = foo.result_type
self.assertEqual(t.kind, TypeKind.INT)
+ def test_result_type_objc_method_decl(self):
+ code = """\
+ @interface Interface : NSObject
+ -(void)voidMethod;
+ @end
+ """
+ tu = get_tu(code, lang='objc')
+ cursor = get_cursor(tu, 'voidMethod')
+ result_type = cursor.result_type
+ self.assertEqual(cursor.kind, CursorKind.OBJC_INSTANCE_METHOD_DECL)
+ self.assertEqual(result_type.kind, TypeKind.VOID)
+
def test_availability(self):
tu = get_tu('class A { A(A const&) = delete; };', lang='cpp')