diff options
Diffstat (limited to 'tools/c-index-test/c-index-test.c')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index fc6ba46fd6..17b773c636 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -1665,34 +1665,55 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p, } } + /* Print if it is an anonymous record decl */ + { + unsigned isAnonRecDecl = clang_Cursor_isAnonymousRecordDecl(cursor); + printf(" [isAnonRecDecl=%d]", isAnonRecDecl); + } + printf("\n"); } return CXChildVisit_Recurse; } -static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p, - CXClientData d) { - CXType T; - enum CXCursorKind K = clang_getCursorKind(cursor); - if (clang_isInvalid(K)) - return CXChildVisit_Recurse; - T = clang_getCursorType(cursor); - PrintCursor(cursor, NULL); - PrintTypeAndTypeKind(T, " [type=%s] [typekind=%s]"); +static void PrintSingleTypeSize(CXType T, const char *TypeKindFormat, + const char *SizeFormat, + const char *AlignFormat) { + PrintTypeAndTypeKind(T, TypeKindFormat); /* Print the type sizeof if applicable. */ { long long Size = clang_Type_getSizeOf(T); if (Size >= 0 || Size < -1 ) { - printf(" [sizeof=%lld]", Size); + printf(SizeFormat, Size); } } /* Print the type alignof if applicable. */ { long long Align = clang_Type_getAlignOf(T); if (Align >= 0 || Align < -1) { - printf(" [alignof=%lld]", Align); + printf(AlignFormat, Align); } } + + /* Print the return type if it exists. */ + { + CXType RT = clang_getResultType(T); + if (RT.kind != CXType_Invalid) + PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]", + " [resultsizeof=%lld]", " [resultalignof=%lld]"); + } +} + +static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p, + CXClientData d) { + CXType T; + enum CXCursorKind K = clang_getCursorKind(cursor); + if (clang_isInvalid(K)) + return CXChildVisit_Recurse; + T = clang_getCursorType(cursor); + PrintCursor(cursor, NULL); + PrintSingleTypeSize(T, " [type=%s] [typekind=%s]", " [sizeof=%lld]", + " [alignof=%lld]"); /* Print the record field offset if applicable. */ { CXString FieldSpelling = clang_getCursorSpelling(cursor); @@ -1730,7 +1751,9 @@ static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p, if (IsBitfield) printf(" [BitFieldSize=%d]", clang_getFieldDeclBitWidth(cursor)); } + printf("\n"); + return CXChildVisit_Recurse; } |