r322672 - [Index] Fix GCC warning. This is silly, but no llvm_unreachable and no C99.

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 07:57:14 PST 2018


Author: sammccall
Date: Wed Jan 17 07:57:14 2018
New Revision: 322672

URL: http://llvm.org/viewvc/llvm-project?rev=322672&view=rev
Log:
[Index] Fix GCC warning. This is silly, but no llvm_unreachable and no C99.

Modified:
    cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=322672&r1=322671&r2=322672&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Jan 17 07:57:14 2018
@@ -724,13 +724,13 @@ static int lineCol_cmp(const void *p1, c
 }
 
 static CXString CursorToText(CXCursor Cursor) {
+  CXString text;
   switch (wanted_display_type) {
   case DisplayType_Spelling:
     return clang_getCursorSpelling(Cursor);
   case DisplayType_DisplayName:
     return clang_getCursorDisplayName(Cursor);
   case DisplayType_Pretty: {
-    CXString text;
     CXPrintingPolicy Policy = clang_getCursorPrintingPolicy(Cursor);
     ModifyPrintingPolicyAccordingToEnv(Policy);
     text = clang_getCursorPrettyPrinted(Cursor, Policy);
@@ -738,6 +738,8 @@ static CXString CursorToText(CXCursor Cu
     return text;
   }
   }
+  assert(0 && "unknown display type"); // no llvm_unreachable in C.
+  return text;                         // garbage
 }
 
 static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) {




More information about the cfe-commits mailing list