[PATCH] D45671: [python bindings] Fix Cursor.result_type for ObjC method declarations - Bug 36677

2018-04-22 Thread Jonathan B Coe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330557: [python bindings] Fix Cursor.result_type for ObjC 
method declarations - Bug… (authored by jbcoe, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D45671

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/bindings/python/tests/cindex/test_cursor.py


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1644,7 +1644,7 @@
 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 @@
[Cursor, c_uint, c_uint],
SourceRange),
 
+  ("clang_getCursorResultType",
+   [Cursor],
+   Type,
+   Type.from_result),
+
   ("clang_getCursorSemanticParent",
[Cursor],
Cursor,
Index: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py
@@ -429,6 +429,18 @@
 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')
 


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1644,7 +1644,7 @@
 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 @@
[Cursor, c_uint, c_uint],
SourceRange),
 
+  ("clang_getCursorResultType",
+   [Cursor],
+   Type,
+   Type.from_result),
+
   ("clang_getCursorSemanticParent",
[Cursor],
Cursor,
Index: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py
@@ -429,6 +429,18 @@
 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')
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45671: [python bindings] Fix Cursor.result_type for ObjC method declarations - Bug 36677

2018-04-22 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

Congrats on your first patch! I can commit this for you.


Repository:
  rC Clang

https://reviews.llvm.org/D45671



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45671: [python bindings] Fix Cursor.result_type for ObjC method declarations - Bug 36677

2018-04-17 Thread Kyle Teske via Phabricator via cfe-commits
kjteske added a comment.

First time llvm contributor here, so no commit access. @jbcoe, can you commit 
this for me?


Repository:
  rC Clang

https://reviews.llvm.org/D45671



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45671: [python bindings] Fix Cursor.result_type for ObjC method declarations - Bug 36677

2018-04-15 Thread Kyle Teske via Phabricator via cfe-commits
kjteske created this revision.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D45671

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


Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -429,6 +429,18 @@
 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')
 
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1644,7 +1644,7 @@
 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 @@
[Cursor, c_uint, c_uint],
SourceRange),
 
+  ("clang_getCursorResultType",
+   [Cursor],
+   Type,
+   Type.from_result),
+
   ("clang_getCursorSemanticParent",
[Cursor],
Cursor,


Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -429,6 +429,18 @@
 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')
 
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1644,7 +1644,7 @@
 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 @@
[Cursor, c_uint, c_uint],
SourceRange),
 
+  ("clang_getCursorResultType",
+   [Cursor],
+   Type,
+   Type.from_result),
+
   ("clang_getCursorSemanticParent",
[Cursor],
Cursor,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits