[cfe-commits] r149842 - in /cfe/trunk/bindings/python: clang/cindex.py tests/cindex/test_type.py
Gregory Szorc
gregory.szorc at gmail.com
Sun Feb 5 11:42:06 PST 2012
Author: gps
Date: Sun Feb 5 13:42:06 2012
New Revision: 149842
URL: http://llvm.org/viewvc/llvm-project?rev=149842&view=rev
Log:
[clang.py] Implement Type.is_pod
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_type.py
Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=149842&r1=149841&r2=149842&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sun Feb 5 13:42:06 2012
@@ -1178,6 +1178,10 @@
"""
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.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
Modified: cfe/trunk/bindings/python/tests/cindex/test_type.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_type.py?rev=149842&r1=149841&r2=149842&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_type.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_type.py Sun Feb 5 13:42:06 2012
@@ -97,3 +97,21 @@
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()
More information about the cfe-commits
mailing list