I have commit access now, so I just need review. The two commits I
just pushed to SVN were approved by Tobias a few weeks ago.

---
 bindings/python/clang/cindex.py           |   10 ++++++++
 bindings/python/tests/cindex/test_type.py |   33 +++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index d38eb1b..d01d1db 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1200,16 +1200,22 @@ class Type(Structure):
     def is_restrict_qualified(self):
         """
         Determine whether a Type has the "restrict" qualifier set,
         without looking through typedefs that may have added
         "restrict" at a different level.
         """
         return Type_is_restrict_qualified(self)
 
+    def is_function_variadic(self):
+        """Determine whether this function Type is a variadic function type."""
+        assert self.kind == TypeKind.FUNCTIONPROTO
+
+        return Type_is_variadic(self)
+
     def is_pod(self):
         """Determine whether this Type represents plain old data (POD)."""
         return Type_is_pod(self)
 
     def get_pointee(self):
         """
         For pointer types, returns the type of the pointee.
         """
@@ -1888,16 +1894,20 @@ Type_is_volatile_qualified.restype = bool
 Type_is_restrict_qualified = lib.clang_isRestrictQualifiedType
 Type_is_restrict_qualified.argtypes = [Type]
 Type_is_restrict_qualified.restype = bool
 
 Type_is_pod = lib.clang_isPODType
 Type_is_pod.argtypes = [Type]
 Type_is_pod.restype = bool
 
+Type_is_variadic = lib.clang_isFunctionTypeVariadic
+Type_is_variadic.argtypes = [Type]
+Type_is_variadic.restype = bool
+
 Type_get_pointee = lib.clang_getPointeeType
 Type_get_pointee.argtypes = [Type]
 Type_get_pointee.restype = Type
 Type_get_pointee.errcheck = Type.from_result
 
 Type_get_declaration = lib.clang_getTypeDeclaration
 Type_get_declaration.argtypes = [Type]
 Type_get_declaration.restype = Cursor
diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py
index ba6af56..da91a8e 100644
--- a/bindings/python/tests/cindex/test_type.py
+++ b/bindings/python/tests/cindex/test_type.py
@@ -16,16 +16,24 @@ struct teststruct {
   signed long e;
   const int f;
   int *g;
   int ***h;
 };
 
 """
 
+def get_tu(source=kInput, lang='cpp'):
+    name = 't.cpp'
+    if lang == 'c':
+        name = 't.c'
+
+    index = Index.create()
+    return index.parse(name, unsaved_files=[(name, source)])
+
 def test_a_struct():
     index = Index.create()
     tu = index.parse('t.c', unsaved_files = [('t.c',kInput)])
 
     for n in tu.cursor.get_children():
         if n.spelling == 'teststruct':
             fields = list(n.get_children())
 
@@ -115,16 +123,41 @@ def test_is_pod():
             f = cursor
 
     assert i is not None
     assert f is not None
 
     assert i.type.is_pod()
     assert not f.type.is_pod()
 
+def test_function_variadic():
+    """Ensure Type.is_function_variadic works."""
+
+    source ="""
+#include <stdarg.h>
+
+void foo(int a, ...);
+void bar(int a, int b);
+"""
+
+    tu = get_tu(source, lang='c')
+    foo, bar = None, None
+    for cursor in tu.cursor.get_children():
+        if cursor.spelling == 'foo':
+            foo = cursor
+        elif cursor.spelling == 'bar':
+            bar = cursor
+
+    ok_(foo is not None)
+    ok_(bar is not None)
+
+    ok_(isinstance(foo.type.is_function_variadic(), bool))
+    ok_(foo.type.is_function_variadic())
+    ok_(not bar.type.is_function_variadic())
+
 def test_element_type():
     index = Index.create()
     tu = index.parse('t.c', unsaved_files=[('t.c', 'int i[5];')])
     assert tu is not None
 
     for cursor in tu.cursor.get_children():
         if cursor.spelling == 'i':
             i = cursor
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to