]> granicus.if.org Git - clang/commitdiff
[clang.py] Implement Type.is_pod
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 5 Feb 2012 19:42:06 +0000 (19:42 +0000)
committerGregory Szorc <gregory.szorc@gmail.com>
Sun, 5 Feb 2012 19:42:06 +0000 (19:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149842 91177308-0d34-0410-b5e6-96231b3b80d8

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

index a5e3ed68450dca254451051d006977918c9a5550..58182f3e09c694d2313a2a1636420e442b34fb88 100644 (file)
@@ -1178,6 +1178,10 @@ class Type(Structure):
         """
         return Type_is_restrict_qualified(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.
@@ -1858,6 +1862,10 @@ 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_get_pointee = lib.clang_getPointeeType
 Type_get_pointee.argtypes = [Type]
 Type_get_pointee.restype = Type
index 2a35f6e7566774b380fc256e22908ab965fa4290..26ed79553e00d9f40e1a79e67f57b7b6388b3630 100644 (file)
@@ -97,3 +97,21 @@ def testConstantArray():
             break
     else:
         assert False, "Didn't find teststruct??"
+
+def test_is_pod():
+    index = Index.create()
+    tu = index.parse('t.c', unsaved_files=[('t.c', 'int i; void f();')])
+    assert tu is not None
+    i, f = None, None
+
+    for cursor in tu.cursor.get_children():
+        if cursor.spelling == 'i':
+            i = cursor
+        elif cursor.spelling == 'f':
+            f = cursor
+
+    assert i is not None
+    assert f is not None
+
+    assert i.type.is_pod()
+    assert not f.type.is_pod()