diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-29 17:22:53 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-01-29 17:22:53 +0000 |
commit | 3c5f2354b8655bd56f4fbfb3a6a862bd14cb3f3f (patch) | |
tree | 0ce5914fa3179fe142febd2a7cf33b1b46c09fc6 /clang/tools/c-index-test | |
parent | 50a20c0e42a97bfd394ad6e71b3ef10bc0ca4063 (diff) | |
download | bcm5719-llvm-3c5f2354b8655bd56f4fbfb3a6a862bd14cb3f3f.tar.gz bcm5719-llvm-3c5f2354b8655bd56f4fbfb3a6a862bd14cb3f3f.zip |
This reverts commit r227432, r227438 and r227448.
It should bring the bots back.
Original messagses:
r227448:
Remove unnecessary default.
r227438:
Fix Index/print-type.cpp test following r227432.
r227432:
libclang: Add three functions useful for dealing with anonymous fields:
clang_Cursor_getOffsetOfField
clang_Cursor_isAnonymous
clang_Type_visitFields
Python: Add corresponding methods for dealing with anonymous fields.
Patch by Loïc Jaquemet
llvm-svn: 227472
Diffstat (limited to 'clang/tools/c-index-test')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 59 |
1 files changed, 18 insertions, 41 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index a49f758e8e9..56e4101399a 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -1250,12 +1250,6 @@ static void PrintTypeAndTypeKind(CXType T, const char *Format) { clang_disposeString(TypeKindSpelling); } -static enum CXVisitorResult FieldVisitor(CXCursor C, - CXClientData client_data) { - (*(int *) client_data)+=1; - return CXVisit_Continue; -} - static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p, CXClientData d) { if (!clang_isInvalid(clang_getCursorKind(cursor))) { @@ -1326,22 +1320,6 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p, PrintTypeAndTypeKind(PT, " [pointeetype=%s] [pointeekind=%s]"); } } - /* Print the number of fields if they exist. */ - { - int numFields = 0; - if (clang_Type_visitFields(T, FieldVisitor, &numFields)){ - if (numFields != 0) { - printf(" [nbFields=%d]", numFields); - } - /* Print if it is an anonymous record. */ - { - unsigned isAnon = clang_Cursor_isAnonymous(cursor); - if (isAnon != 0) { - printf(" [isAnon=%d]", isAnon); - } - } - } - } printf("\n"); } @@ -1375,29 +1353,28 @@ static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p, { CXString FieldSpelling = clang_getCursorSpelling(cursor); const char *FieldName = clang_getCString(FieldSpelling); - /* recurse to get the first parent record that is not anonymous. */ - CXCursor Parent, Record; - unsigned RecordIsAnonymous = 0; + /* recurse to get the root anonymous record parent */ + CXCursor Parent, Root; if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) { - Record = Parent = p; + CXString RootParentSpelling; + const char *RootParentName = 0; + Parent = p; do { - Record = Parent; - Parent = clang_getCursorSemanticParent(Record); - RecordIsAnonymous = clang_Cursor_isAnonymous(Record); - /* Recurse as long as the parent is a CXType_Record and the Record - is anonymous */ - } while ( clang_getCursorType(Parent).kind == CXType_Record && - RecordIsAnonymous > 0); + if (RootParentName != 0) + clang_disposeString(RootParentSpelling); + + Root = Parent; + RootParentSpelling = clang_getCursorSpelling(Root); + RootParentName = clang_getCString(RootParentSpelling); + Parent = clang_getCursorSemanticParent(Root); + } while (clang_getCursorType(Parent).kind == CXType_Record && + !strcmp(RootParentName, "")); + clang_disposeString(RootParentSpelling); + /* if RootParentName is "", record is anonymous. */ { - long long Offset = clang_Type_getOffsetOf(clang_getCursorType(Record), + long long Offset = clang_Type_getOffsetOf(clang_getCursorType(Root), FieldName); - long long Offset2 = clang_Cursor_getOffsetOfField(cursor); - if (Offset == Offset2){ - printf(" [offsetof=%lld]", Offset); - } else { - /* Offsets will be different in anonymous records. */ - printf(" [offsetof=%lld/%lld]", Offset, Offset2); - } + printf(" [offsetof=%lld]", Offset); } } clang_disposeString(FieldSpelling); |