[cfe-commits] r109822 - in /cfe/trunk: include/clang-c/Index.h test/Index/print-typekind.c tools/c-index-test/c-index-test.c tools/libclang/CXTypes.cpp tools/libclang/libclang.darwin.exports tools/libclang/libclang.exports
Ted Kremenek
kremenek at apple.com
Thu Jul 29 17:14:11 PDT 2010
Author: kremenek
Date: Thu Jul 29 19:14:11 2010
New Revision: 109822
URL: http://llvm.org/viewvc/llvm-project?rev=109822&view=rev
Log:
Add clang_isPODType() for querying if the CXType is POD. Implements <rdar://problem/8250669>.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-typekind.c
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXTypes.cpp
cfe/trunk/tools/libclang/libclang.darwin.exports
cfe/trunk/tools/libclang/libclang.exports
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=109822&r1=109821&r2=109822&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Jul 29 19:14:11 2010
@@ -1295,6 +1295,12 @@
CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
/**
+ * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
+ * otherwise.
+ */
+CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
+
+/**
* @}
*/
Modified: cfe/trunk/test/Index/print-typekind.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-typekind.c?rev=109822&r1=109821&r2=109822&view=diff
==============================================================================
--- cfe/trunk/test/Index/print-typekind.c (original)
+++ cfe/trunk/test/Index/print-typekind.c Thu Jul 29 19:14:11 2010
@@ -6,15 +6,20 @@
}
// RUN: c-index-test -test-print-typekind %s | FileCheck %s
-// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int]
-// CHECK: VarDecl=p:2:6 typekind=Pointer
-// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer]
-// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer
-// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer
-// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int]
-// CHECK: VarDecl=w:4:11 (Definition) typekind=Typedef [canonical=Int]
-// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int]
-// CHECK: UnexposedExpr= typekind=Pointer
-// CHECK: DeclRefExpr=p:3:13 typekind=Pointer
-// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int]
+// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: VarDecl=p:2:6 typekind=Pointer [isPOD=1]
+// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [isPOD=0]
+// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer [isPOD=1]
+// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer [isPOD=1]
+// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: TypeRef=FooType:1:13 typekind=Invalid [isPOD=0]
+// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0]
+// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0]
+// CHECK: VarDecl=w:4:11 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: TypeRef=FooType:1:13 typekind=Invalid [isPOD=0]
+// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0]
+// CHECK: UnexposedExpr= typekind=Pointer [isPOD=1]
+// CHECK: DeclRefExpr=p:3:13 typekind=Pointer [isPOD=1]
+// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1]
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=109822&r1=109821&r2=109822&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jul 29 19:14:11 2010
@@ -487,6 +487,8 @@
clang_disposeString(RS);
}
}
+ /* Print if this is a non-POD type. */
+ printf(" [isPOD=%d]", clang_isPODType(T));
printf("\n");
}
Modified: cfe/trunk/tools/libclang/CXTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXTypes.cpp?rev=109822&r1=109821&r2=109822&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXTypes.cpp (original)
+++ cfe/trunk/tools/libclang/CXTypes.cpp Thu Jul 29 19:14:11 2010
@@ -283,4 +283,11 @@
return MakeCXType(QualType(), cxcursor::getCursorASTUnit(C));
}
+unsigned clang_isPODType(CXType X) {
+ QualType T = GetQualType(X);
+ if (!T.getTypePtr())
+ return 0;
+ return T->isPODType() ? 1 : 0;
+}
+
} // end: extern "C"
Modified: cfe/trunk/tools/libclang/libclang.darwin.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.darwin.exports?rev=109822&r1=109821&r2=109822&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.darwin.exports (original)
+++ cfe/trunk/tools/libclang/libclang.darwin.exports Thu Jul 29 19:14:11 2010
@@ -82,6 +82,7 @@
_clang_isExpression
_clang_isInvalid
_clang_isPreprocessing
+_clang_isPODType
_clang_isReference
_clang_isStatement
_clang_isTranslationUnit
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=109822&r1=109821&r2=109822&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Thu Jul 29 19:14:11 2010
@@ -82,6 +82,7 @@
clang_isExpression
clang_isInvalid
clang_isPreprocessing
+clang_isPODType
clang_isReference
clang_isStatement
clang_isTranslationUnit
More information about the cfe-commits
mailing list