Add CXType and an initial set of supporting functions to libclang. This exposes details of
Clang's representation of the C type system to clients. It is nowhere near complete, and will
be expanded on demand.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103809 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 4941816..12fede2 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -447,6 +447,31 @@
}
/******************************************************************************/
+/* Typekind testing. */
+/******************************************************************************/
+
+static enum CXChildVisitResult PrintTypeKind(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+
+ if (!clang_isInvalid(clang_getCursorKind(cursor))) {
+ CXType T = clang_getCursorType(cursor);
+ CXType CT = clang_getCanonicalType(T);
+ CXString S = clang_getTypeKindSpelling(T.kind);
+ PrintCursor(cursor);
+ printf(" typekind=%s", clang_getCString(S));
+ if (!clang_equalTypes(T, CT)) {
+ CXString CS = clang_getTypeKindSpelling(CT.kind);
+ printf(" [canonical=%s]", clang_getCString(CS));
+ clang_disposeString(CS);
+ }
+ clang_disposeString(S);
+ printf("\n");
+ }
+ return CXChildVisit_Recurse;
+}
+
+
+/******************************************************************************/
/* Loading ASTs/source. */
/******************************************************************************/
@@ -1179,6 +1204,7 @@
" c-index-test -test-inclusion-stack-source {<args>}*\n"
" c-index-test -test-inclusion-stack-tu <AST file>\n"
" c-index-test -test-print-linkage-source {<args>}*\n"
+ " c-index-test -test-print-typekind {<args>}*\n"
" c-index-test -print-usr [<CursorKind> {<args>}]*\n"
" c-index-test -print-usr-file <file>\n\n"
" <symbol filter> values:\n%s",
@@ -1223,6 +1249,9 @@
else if (argc > 2 && strcmp(argv[1], "-test-print-linkage-source") == 0)
return perform_test_load_source(argc - 2, argv + 2, "all", PrintLinkage,
NULL);
+ else if (argc > 2 && strcmp(argv[1], "-test-print-typekind") == 0)
+ return perform_test_load_source(argc - 2, argv + 2, "all",
+ PrintTypeKind, 0);
else if (argc > 1 && strcmp(argv[1], "-print-usr") == 0) {
if (argc > 2)
return print_usrs(argv + 2, argv + argc);