Add clang_isPODType() for querying if the CXType is POD.  Implements <rdar://problem/8250669>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109822 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 30feb41..49a1161 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -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);
+
+/**
  * @}
  */
 
diff --git a/test/Index/print-typekind.c b/test/Index/print-typekind.c
index 13b4119..18189c3 100644
--- a/test/Index/print-typekind.c
+++ b/test/Index/print-typekind.c
@@ -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]
 
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index b8d4cb8..795c19c 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -487,6 +487,8 @@
         clang_disposeString(RS);
       }
     }
+    /* Print if this is a non-POD type. */
+    printf(" [isPOD=%d]", clang_isPODType(T));
 
     printf("\n");
   }
diff --git a/tools/libclang/CXTypes.cpp b/tools/libclang/CXTypes.cpp
index d5c9f45..b49ef19 100644
--- a/tools/libclang/CXTypes.cpp
+++ b/tools/libclang/CXTypes.cpp
@@ -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"
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index e51620c..50ed994 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -82,6 +82,7 @@
 _clang_isExpression
 _clang_isInvalid
 _clang_isPreprocessing
+_clang_isPODType
 _clang_isReference
 _clang_isStatement
 _clang_isTranslationUnit
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index 3d3e713..752c650 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -82,6 +82,7 @@
 clang_isExpression
 clang_isInvalid
 clang_isPreprocessing
+clang_isPODType
 clang_isReference
 clang_isStatement
 clang_isTranslationUnit