From 6bca984b5438540fd6433e9fa10009241a139fbb Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 14 May 2010 21:29:26 +0000 Subject: 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. llvm-svn: 103809 --- clang/tools/c-index-test/c-index-test.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'clang/tools/c-index-test/c-index-test.c') diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 494181675c5..12fede209e8 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -446,6 +446,31 @@ static enum CXChildVisitResult PrintLinkage(CXCursor cursor, CXCursor p, return CXChildVisit_Recurse; } +/******************************************************************************/ +/* 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 @@ static void print_usage(void) { " c-index-test -test-inclusion-stack-source {}*\n" " c-index-test -test-inclusion-stack-tu \n" " c-index-test -test-print-linkage-source {}*\n" + " c-index-test -test-print-typekind {}*\n" " c-index-test -print-usr [ {}]*\n" " c-index-test -print-usr-file \n\n" " values:\n%s", @@ -1223,6 +1249,9 @@ int main(int argc, const char **argv) { 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); -- cgit v1.2.3