From: Ted Kremenek Date: Sat, 16 Jan 2010 02:02:09 +0000 (+0000) Subject: Remove 'default' case in switch statement in clang_getCursorKindSpelling(). This... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=deb06bd3566e18f677e76bc435d478b033fe328b;p=clang Remove 'default' case in switch statement in clang_getCursorKindSpelling(). This identified a missing case (warned by the compiler) and identified that CXCursor_FirstDecl didn't actually correspond to the first decl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93622 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 79ec0f8a4c..4c9f3a36d0 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -55,24 +55,24 @@ typedef void *CXStmt; /* A specific statement within a function/method */ enum CXCursorKind { /* Declarations */ CXCursor_FirstDecl = 1, - CXCursor_TypedefDecl = 2, - CXCursor_StructDecl = 3, - CXCursor_UnionDecl = 4, - CXCursor_ClassDecl = 5, - CXCursor_EnumDecl = 6, - CXCursor_FieldDecl = 7, - CXCursor_EnumConstantDecl = 8, - CXCursor_FunctionDecl = 9, - CXCursor_VarDecl = 10, - CXCursor_ParmDecl = 11, - CXCursor_ObjCInterfaceDecl = 12, - CXCursor_ObjCCategoryDecl = 13, - CXCursor_ObjCProtocolDecl = 14, - CXCursor_ObjCPropertyDecl = 15, - CXCursor_ObjCIvarDecl = 16, - CXCursor_ObjCInstanceMethodDecl = 17, - CXCursor_ObjCClassMethodDecl = 18, - CXCursor_LastDecl = 18, + CXCursor_TypedefDecl = 1, + CXCursor_StructDecl = 2, + CXCursor_UnionDecl = 3, + CXCursor_ClassDecl = 4, + CXCursor_EnumDecl = 5, + CXCursor_FieldDecl = 6, + CXCursor_EnumConstantDecl = 7, + CXCursor_FunctionDecl = 8, + CXCursor_VarDecl = 9, + CXCursor_ParmDecl = 10, + CXCursor_ObjCInterfaceDecl = 11, + CXCursor_ObjCCategoryDecl = 12, + CXCursor_ObjCProtocolDecl = 13, + CXCursor_ObjCPropertyDecl = 14, + CXCursor_ObjCIvarDecl = 15, + CXCursor_ObjCInstanceMethodDecl = 16, + CXCursor_ObjCClassMethodDecl = 17, + CXCursor_LastDecl = 17, /* Definitions */ CXCursor_FirstDefn = 32, diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index f297aceed2..0ecb54a86f 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -811,6 +811,7 @@ const char *clang_getCursorKindSpelling(enum CXCursorKind Kind) { case CXCursor_UnionDecl: return "UnionDecl"; case CXCursor_ClassDecl: return "ClassDecl"; case CXCursor_FieldDecl: return "FieldDecl"; + case CXCursor_FunctionDefn: return "FunctionDefn"; case CXCursor_VarDecl: return "VarDecl"; case CXCursor_ParmDecl: return "ParmDecl"; case CXCursor_ObjCInterfaceDecl: return "ObjCInterfaceDecl"; @@ -818,13 +819,13 @@ const char *clang_getCursorKindSpelling(enum CXCursorKind Kind) { case CXCursor_ObjCProtocolDecl: return "ObjCProtocolDecl"; case CXCursor_ObjCPropertyDecl: return "ObjCPropertyDecl"; case CXCursor_ObjCIvarDecl: return "ObjCIvarDecl"; + case CXCursor_ObjCIvarRef: return "ObjCIvarRef"; case CXCursor_ObjCInstanceMethodDecl: return "ObjCInstanceMethodDecl"; case CXCursor_ObjCClassMethodDecl: return "ObjCClassMethodDecl"; - case CXCursor_FunctionDefn: return "FunctionDefn"; case CXCursor_ObjCInstanceMethodDefn: return "ObjCInstanceMethodDefn"; + case CXCursor_ObjCCategoryDefn: return "ObjCCategoryDefn"; case CXCursor_ObjCClassMethodDefn: return "ObjCClassMethodDefn"; case CXCursor_ObjCClassDefn: return "ObjCClassDefn"; - case CXCursor_ObjCCategoryDefn: return "ObjCCategoryDefn"; case CXCursor_ObjCSuperClassRef: return "ObjCSuperClassRef"; case CXCursor_ObjCProtocolRef: return "ObjCProtocolRef"; case CXCursor_ObjCClassRef: return "ObjCClassRef"; @@ -838,8 +839,10 @@ const char *clang_getCursorKindSpelling(enum CXCursorKind Kind) { case CXCursor_InvalidFile: return "InvalidFile"; case CXCursor_NoDeclFound: return "NoDeclFound"; case CXCursor_NotImplemented: return "NotImplemented"; - default: return ""; } + + llvm_unreachable("Unhandled CXCursorKind"); + return NULL; } CXCursor clang_getCursor(CXTranslationUnit CTUnit, const char *source_name, @@ -901,8 +904,7 @@ unsigned clang_equalCursors(CXCursor X, CXCursor Y) { CXCursor clang_getCursorFromDecl(CXDecl AnonDecl) { assert(AnonDecl && "Passed null CXDecl"); - NamedDecl *ND = static_cast(AnonDecl); - return MakeCXCursor(ND); + return MakeCXCursor(static_cast(AnonDecl)); } unsigned clang_isInvalid(enum CXCursorKind K) {