Add CXType support for FunctionNoProto and FunctionProto types. This includes adding a new
function, clang_getResultType(), which returns the result type of the function type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106459 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 4268cec..27c51a0 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -455,16 +455,29 @@
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);
+ // Print the canonical type if it is different.
+ {
+ CXType CT = clang_getCanonicalType(T);
+ if (!clang_equalTypes(T, CT)) {
+ CXString CS = clang_getTypeKindSpelling(CT.kind);
+ printf(" [canonical=%s]", clang_getCString(CS));
+ clang_disposeString(CS);
+ }
+ }
+ // Print the return type if it exists.
+ {
+ CXType RT = clang_getResultType(T);
+ if (RT.kind != CXType_Invalid) {
+ CXString RS = clang_getTypeKindSpelling(RT.kind);
+ printf(" [result=%s]", clang_getCString(RS));
+ clang_disposeString(RS);
+ }
+ }
+
printf("\n");
}
return CXChildVisit_Recurse;