]> granicus.if.org Git - clang/commitdiff
Add clang_isPODType() for querying if the CXType is POD. Implements <rdar://problem...
authorTed Kremenek <kremenek@apple.com>
Fri, 30 Jul 2010 00:14:11 +0000 (00:14 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 30 Jul 2010 00:14:11 +0000 (00:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109822 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 30feb41f3339f18d13f70e3a0a2e1d9a6abbd0bd..49a11612be5a8a435c9e7ecc54c1a052f3385bd5 100644 (file)
@@ -1294,6 +1294,12 @@ CINDEX_LINKAGE CXType clang_getResultType(CXType T);
  */
 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);
+
 /**
  * @}
  */
index 13b41198f127818f6f0f88bd4a3fffee0346da82..18189c3c74acef923cb01008c06a563967214dfb 100644 (file)
@@ -6,15 +6,20 @@ int *f(int *p, char *x, FooType z) {
 }
 
 // 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]
 
index b8d4cb89178e0958d2f4086e824b54713e92ad1f..795c19c0cb5ab7c973818c0740549de15b4e6160 100644 (file)
@@ -487,6 +487,8 @@ static enum CXChildVisitResult PrintTypeKind(CXCursor cursor, CXCursor p,
         clang_disposeString(RS);
       }
     }
+    /* Print if this is a non-POD type. */
+    printf(" [isPOD=%d]", clang_isPODType(T));
 
     printf("\n");
   }
index d5c9f452100b02bd3143c7fe1c78cf31e1524975..b49ef191e3cccc1e801c3eb7e9bc8b51f1130393 100644 (file)
@@ -283,4 +283,11 @@ CXType clang_getCursorResultType(CXCursor C) {
   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"
index e51620c786458de5a20747a1f4cc5a88ce2f361f..50ed994b1fedae60197ee1348bc8806ba6ec5274 100644 (file)
@@ -82,6 +82,7 @@ _clang_isDeclaration
 _clang_isExpression
 _clang_isInvalid
 _clang_isPreprocessing
+_clang_isPODType
 _clang_isReference
 _clang_isStatement
 _clang_isTranslationUnit
index 3d3e7138c86feea21bdedcfd28c43f0011046a8d..752c6504c9bd6930c9af1914a5ff63b1d5925d76 100644 (file)
@@ -82,6 +82,7 @@ clang_isDeclaration
 clang_isExpression
 clang_isInvalid
 clang_isPreprocessing
+clang_isPODType
 clang_isReference
 clang_isStatement
 clang_isTranslationUnit