Steve Naroff | 2b8ee6c | 2009-09-01 15:55:40 +0000 | [diff] [blame] | 1 | /* c-index-test.c */ |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 2 | |
| 3 | #include "clang-c/Index.h" |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 4 | #include <stdlib.h> |
Steve Naroff | 89922f8 | 2009-08-31 00:59:03 +0000 | [diff] [blame] | 5 | #include <stdio.h> |
Steve Naroff | af08ddc | 2009-09-03 15:49:00 +0000 | [diff] [blame] | 6 | #include <string.h> |
| 7 | |
John Thompson | 2e06fc8 | 2009-10-27 13:42:56 +0000 | [diff] [blame] | 8 | #ifdef _MSC_VER |
| 9 | char *basename(const char* path) |
| 10 | { |
| 11 | char* base1 = (char*)strrchr(path, '/'); |
| 12 | char* base2 = (char*)strrchr(path, '\\'); |
| 13 | if (base1 && base2) |
| 14 | return((base1 > base2) ? base1 + 1 : base2 + 1); |
| 15 | else if (base1) |
| 16 | return(base1 + 1); |
| 17 | else if (base2) |
| 18 | return(base2 + 1); |
| 19 | |
| 20 | return((char*)path); |
| 21 | } |
| 22 | #else |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 23 | extern char *basename(const char *); |
John Thompson | 2e06fc8 | 2009-10-27 13:42:56 +0000 | [diff] [blame] | 24 | #endif |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 25 | |
Steve Naroff | af08ddc | 2009-09-03 15:49:00 +0000 | [diff] [blame] | 26 | static void PrintCursor(CXCursor Cursor) { |
Steve Naroff | 77128dd | 2009-09-15 20:25:34 +0000 | [diff] [blame] | 27 | if (clang_isInvalid(Cursor.kind)) |
| 28 | printf("Invalid Cursor => %s\n", clang_getCursorKindSpelling(Cursor.kind)); |
Steve Naroff | 699a07d | 2009-09-25 21:32:34 +0000 | [diff] [blame] | 29 | else { |
Eric Christopher | f393c3b | 2009-10-05 21:33:42 +0000 | [diff] [blame] | 30 | CXDecl DeclReferenced; |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 31 | CXString string; |
| 32 | string = clang_getCursorSpelling(Cursor); |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 33 | printf("%s=%s", clang_getCursorKindSpelling(Cursor.kind), |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 34 | clang_getCString(string)); |
| 35 | clang_disposeString(string); |
Eric Christopher | f393c3b | 2009-10-05 21:33:42 +0000 | [diff] [blame] | 36 | DeclReferenced = clang_getCursorDecl(Cursor); |
Steve Naroff | 85e2db7 | 2009-10-01 00:31:07 +0000 | [diff] [blame] | 37 | if (DeclReferenced) |
| 38 | printf(":%d:%d", clang_getDeclLine(DeclReferenced), |
| 39 | clang_getDeclColumn(DeclReferenced)); |
Steve Naroff | 699a07d | 2009-09-25 21:32:34 +0000 | [diff] [blame] | 40 | } |
Steve Naroff | af08ddc | 2009-09-03 15:49:00 +0000 | [diff] [blame] | 41 | } |
Steve Naroff | 89922f8 | 2009-08-31 00:59:03 +0000 | [diff] [blame] | 42 | |
Ted Kremenek | 9298cfc | 2009-11-17 05:31:58 +0000 | [diff] [blame] | 43 | static const char* GetCursorSource(CXCursor Cursor) { |
| 44 | const char *source = clang_getCursorSource(Cursor); |
| 45 | if (!source) |
| 46 | return "<invalid loc>"; |
| 47 | return basename(source); |
| 48 | } |
| 49 | |
Eric Christopher | f393c3b | 2009-10-05 21:33:42 +0000 | [diff] [blame] | 50 | static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter) |
Steve Naroff | c857ea4 | 2009-09-02 13:28:54 +0000 | [diff] [blame] | 51 | { |
Daniel Dunbar | bce6f62 | 2009-09-03 05:59:50 +0000 | [diff] [blame] | 52 | if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 53 | CXString string; |
Ted Kremenek | 9298cfc | 2009-11-17 05:31:58 +0000 | [diff] [blame] | 54 | printf("// CHECK: %s:%d:%d: ", GetCursorSource(Cursor), |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 55 | clang_getCursorLine(Cursor), |
| 56 | clang_getCursorColumn(Cursor)); |
Steve Naroff | af08ddc | 2009-09-03 15:49:00 +0000 | [diff] [blame] | 57 | PrintCursor(Cursor); |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 58 | string = clang_getDeclSpelling(Dcl); |
| 59 | printf(" [Context=%s]\n", clang_getCString(string)); |
| 60 | clang_disposeString(string); |
Daniel Dunbar | bce6f62 | 2009-09-03 05:59:50 +0000 | [diff] [blame] | 61 | } |
Steve Naroff | c857ea4 | 2009-09-02 13:28:54 +0000 | [diff] [blame] | 62 | } |
| 63 | static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, |
Eric Christopher | f393c3b | 2009-10-05 21:33:42 +0000 | [diff] [blame] | 64 | CXClientData Filter) |
Steve Naroff | c857ea4 | 2009-09-02 13:28:54 +0000 | [diff] [blame] | 65 | { |
| 66 | if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 67 | CXString string; |
Ted Kremenek | 9298cfc | 2009-11-17 05:31:58 +0000 | [diff] [blame] | 68 | printf("// CHECK: %s:%d:%d: ", GetCursorSource(Cursor), |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 69 | clang_getCursorLine(Cursor), |
| 70 | clang_getCursorColumn(Cursor)); |
Steve Naroff | af08ddc | 2009-09-03 15:49:00 +0000 | [diff] [blame] | 71 | PrintCursor(Cursor); |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 72 | string = clang_getTranslationUnitSpelling(Unit); |
| 73 | printf(" [Context=%s]\n", |
| 74 | basename(clang_getCString(string))); |
| 75 | clang_disposeString(string); |
Steve Naroff | ff9e18c | 2009-09-24 20:03:06 +0000 | [diff] [blame] | 76 | |
| 77 | clang_loadDeclaration(Cursor.decl, DeclVisitor, 0); |
Steve Naroff | c857ea4 | 2009-09-02 13:28:54 +0000 | [diff] [blame] | 78 | |
Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 79 | if (Cursor.kind == CXCursor_FunctionDefn) { |
| 80 | const char *startBuf, *endBuf; |
| 81 | unsigned startLine, startColumn, endLine, endColumn; |
| 82 | clang_getDefinitionSpellingAndExtent(Cursor, &startBuf, &endBuf, |
| 83 | &startLine, &startColumn, |
| 84 | &endLine, &endColumn); |
Steve Naroff | f7469a3 | 2009-09-23 20:00:53 +0000 | [diff] [blame] | 85 | { |
| 86 | /* Probe the entire body, looking for both decls and refs. */ |
| 87 | unsigned curLine = startLine, curColumn = startColumn; |
| 88 | CXCursor Ref; |
Eric Christopher | f393c3b | 2009-10-05 21:33:42 +0000 | [diff] [blame] | 89 | |
Steve Naroff | 6a6de8b | 2009-10-21 13:56:23 +0000 | [diff] [blame] | 90 | while (startBuf < endBuf) { |
Steve Naroff | f7469a3 | 2009-09-23 20:00:53 +0000 | [diff] [blame] | 91 | if (*startBuf == '\n') { |
| 92 | startBuf++; |
| 93 | curLine++; |
| 94 | curColumn = 1; |
| 95 | } else if (*startBuf != '\t') |
| 96 | curColumn++; |
Ted Kremenek | fbcb2b7 | 2009-10-22 17:22:53 +0000 | [diff] [blame] | 97 | |
Steve Naroff | f96b524 | 2009-10-28 20:44:47 +0000 | [diff] [blame] | 98 | Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor), |
| 99 | curLine, curColumn); |
Douglas Gregor | 0246575 | 2009-10-16 21:24:31 +0000 | [diff] [blame] | 100 | if (Ref.kind == CXCursor_NoDeclFound) { |
Ted Kremenek | 8ce88a4 | 2009-10-17 06:37:16 +0000 | [diff] [blame] | 101 | /* Nothing found here; that's fine. */ |
Douglas Gregor | 0246575 | 2009-10-16 21:24:31 +0000 | [diff] [blame] | 102 | } else if (Ref.kind != CXCursor_FunctionDecl) { |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 103 | CXString string; |
Ted Kremenek | 9298cfc | 2009-11-17 05:31:58 +0000 | [diff] [blame] | 104 | printf("// CHECK: %s:%d:%d: ", GetCursorSource(Ref), |
| 105 | curLine, curColumn); |
Steve Naroff | f7469a3 | 2009-09-23 20:00:53 +0000 | [diff] [blame] | 106 | PrintCursor(Ref); |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 107 | string = clang_getDeclSpelling(Ref.decl); |
| 108 | printf(" [Context:%s]\n", clang_getCString(string)); |
| 109 | clang_disposeString(string); |
Steve Naroff | f7469a3 | 2009-09-23 20:00:53 +0000 | [diff] [blame] | 110 | } |
Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 111 | startBuf++; |
Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 112 | } |
Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 113 | } |
| 114 | } |
Steve Naroff | 2d4d629 | 2009-08-31 14:26:51 +0000 | [diff] [blame] | 115 | } |
Steve Naroff | 89922f8 | 2009-08-31 00:59:03 +0000 | [diff] [blame] | 116 | } |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 117 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 118 | /* Parse file:line:column from the input string. Returns 0 on success, non-zero |
| 119 | on failure. If successful, the pointer *filename will contain newly-allocated |
| 120 | memory (that will be owned by the caller) to store the file name. */ |
| 121 | int parse_file_line_column(const char *input, char **filename, unsigned *line, |
| 122 | unsigned *column) { |
Douglas Gregor | 88d2395 | 2009-11-09 18:19:57 +0000 | [diff] [blame] | 123 | /* Find the second colon. */ |
| 124 | const char *second_colon = strrchr(input, ':'), *first_colon; |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 125 | char *endptr = 0; |
Douglas Gregor | 88d2395 | 2009-11-09 18:19:57 +0000 | [diff] [blame] | 126 | if (!second_colon || second_colon == input) { |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 127 | fprintf(stderr, "could not parse filename:line:column in '%s'\n", input); |
| 128 | return 1; |
| 129 | } |
| 130 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 131 | /* Parse the column number. */ |
Douglas Gregor | 88d2395 | 2009-11-09 18:19:57 +0000 | [diff] [blame] | 132 | *column = strtol(second_colon + 1, &endptr, 10); |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 133 | if (*endptr != 0) { |
| 134 | fprintf(stderr, "could not parse column in '%s'\n", input); |
Douglas Gregor | 88d2395 | 2009-11-09 18:19:57 +0000 | [diff] [blame] | 135 | return 1; |
| 136 | } |
| 137 | |
| 138 | /* Find the first colon. */ |
| 139 | first_colon = second_colon - 1; |
| 140 | while (first_colon != input && *first_colon != ':') |
| 141 | --first_colon; |
| 142 | if (first_colon == input) { |
| 143 | fprintf(stderr, "could not parse line in '%s'\n", input); |
| 144 | return 1; |
| 145 | } |
| 146 | |
| 147 | /* Parse the line number. */ |
| 148 | *line = strtol(first_colon + 1, &endptr, 10); |
| 149 | if (*endptr != ':') { |
| 150 | fprintf(stderr, "could not parse line in '%s'\n", input); |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 151 | return 1; |
| 152 | } |
| 153 | |
Douglas Gregor | 88d2395 | 2009-11-09 18:19:57 +0000 | [diff] [blame] | 154 | /* Copy the file name. */ |
| 155 | *filename = (char*)malloc(first_colon - input + 1); |
| 156 | memcpy(*filename, input, first_colon - input); |
| 157 | (*filename)[first_colon - input] = 0; |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | const char * |
| 162 | clang_getCompletionChunkKindSpelling(enum CXCompletionChunkKind Kind) { |
| 163 | switch (Kind) { |
| 164 | case CXCompletionChunk_Optional: return "Optional"; |
| 165 | case CXCompletionChunk_TypedText: return "TypedText"; |
| 166 | case CXCompletionChunk_Text: return "Text"; |
| 167 | case CXCompletionChunk_Placeholder: return "Placeholder"; |
| 168 | case CXCompletionChunk_Informative: return "Informative"; |
| 169 | case CXCompletionChunk_CurrentParameter: return "CurrentParameter"; |
| 170 | case CXCompletionChunk_LeftParen: return "LeftParen"; |
| 171 | case CXCompletionChunk_RightParen: return "RightParen"; |
| 172 | case CXCompletionChunk_LeftBracket: return "LeftBracket"; |
| 173 | case CXCompletionChunk_RightBracket: return "RightBracket"; |
| 174 | case CXCompletionChunk_LeftBrace: return "LeftBrace"; |
| 175 | case CXCompletionChunk_RightBrace: return "RightBrace"; |
| 176 | case CXCompletionChunk_LeftAngle: return "LeftAngle"; |
| 177 | case CXCompletionChunk_RightAngle: return "RightAngle"; |
| 178 | case CXCompletionChunk_Comma: return "Comma"; |
| 179 | } |
| 180 | |
| 181 | return "Unknown"; |
| 182 | } |
| 183 | |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 184 | void print_completion_string(CXCompletionString completion_string, FILE *file) { |
Daniel Dunbar | f8297f1 | 2009-11-07 18:34:24 +0000 | [diff] [blame] | 185 | int I, N; |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 186 | |
| 187 | N = clang_getNumCompletionChunks(completion_string); |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 188 | for (I = 0; I != N; ++I) { |
Douglas Gregor | d5a2089 | 2009-11-09 17:05:28 +0000 | [diff] [blame] | 189 | const char *text = 0; |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 190 | enum CXCompletionChunkKind Kind |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 191 | = clang_getCompletionChunkKind(completion_string, I); |
| 192 | |
| 193 | if (Kind == CXCompletionChunk_Optional) { |
| 194 | fprintf(file, "{Optional "); |
| 195 | print_completion_string( |
| 196 | clang_getCompletionChunkCompletionString(completion_string, I), |
| 197 | file); |
| 198 | fprintf(file, "}"); |
| 199 | continue; |
| 200 | } |
| 201 | |
Douglas Gregor | d5a2089 | 2009-11-09 17:05:28 +0000 | [diff] [blame] | 202 | text = clang_getCompletionChunkText(completion_string, I); |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 203 | fprintf(file, "{%s %s}", |
| 204 | clang_getCompletionChunkKindSpelling(Kind), |
| 205 | text? text : ""); |
| 206 | } |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | void print_completion_result(CXCompletionResult *completion_result, |
| 210 | CXClientData client_data) { |
| 211 | FILE *file = (FILE *)client_data; |
| 212 | fprintf(file, "%s:", |
| 213 | clang_getCursorKindSpelling(completion_result->CursorKind)); |
| 214 | print_completion_string(completion_result->CompletionString, file); |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 215 | fprintf(file, "\n"); |
| 216 | } |
| 217 | |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 218 | int perform_code_completion(int argc, const char **argv) { |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 219 | const char *input = argv[1]; |
| 220 | char *filename = 0; |
| 221 | unsigned line; |
| 222 | unsigned column; |
Daniel Dunbar | f8297f1 | 2009-11-07 18:34:24 +0000 | [diff] [blame] | 223 | CXIndex CIdx; |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 224 | int errorCode; |
Daniel Dunbar | f8297f1 | 2009-11-07 18:34:24 +0000 | [diff] [blame] | 225 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 226 | input += strlen("-code-completion-at="); |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 227 | if ((errorCode = parse_file_line_column(input, &filename, &line, &column))) |
| 228 | return errorCode; |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 229 | |
Daniel Dunbar | f8297f1 | 2009-11-07 18:34:24 +0000 | [diff] [blame] | 230 | CIdx = clang_createIndex(0, 0); |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 231 | clang_codeComplete(CIdx, argv[argc - 1], argc - 3, argv + 2, |
| 232 | filename, line, column, &print_completion_result, stdout); |
| 233 | clang_disposeIndex(CIdx); |
| 234 | free(filename); |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 235 | |
| 236 | return 0; |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 239 | int perform_test_load_tu(const char *file, const char *filter) { |
Ted Kremenek | 85f5468 | 2009-10-17 06:42:15 +0000 | [diff] [blame] | 240 | CXIndex Idx; |
| 241 | CXTranslationUnit TU; |
| 242 | enum CXCursorKind K = CXCursor_NotImplemented; |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 243 | enum CXCursorKind *ck = &K; |
| 244 | Idx = clang_createIndex(/* excludeDeclsFromPCH */ |
| 245 | !strcmp(filter, "local") ? 1 : 0, |
Steve Naroff | e56b4ba | 2009-10-20 14:46:24 +0000 | [diff] [blame] | 246 | /* displayDiagnostics */ 1); |
Ted Kremenek | 85f5468 | 2009-10-17 06:42:15 +0000 | [diff] [blame] | 247 | |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 248 | TU = clang_createTranslationUnit(Idx, file); |
| 249 | |
Douglas Gregor | 7d1d49d | 2009-10-16 20:01:17 +0000 | [diff] [blame] | 250 | if (!TU) { |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 251 | fprintf(stderr, "Unable to load translation unit from '%s'!\n", file); |
Douglas Gregor | 7d1d49d | 2009-10-16 20:01:17 +0000 | [diff] [blame] | 252 | return 1; |
| 253 | } |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 254 | |
Steve Naroff | f7469a3 | 2009-09-23 20:00:53 +0000 | [diff] [blame] | 255 | /* Perform some simple filtering. */ |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 256 | if (!strcmp(filter, "all") || !strcmp(filter, "local")) ck = NULL; |
| 257 | else if (!strcmp(filter, "category")) K = CXCursor_ObjCCategoryDecl; |
| 258 | else if (!strcmp(filter, "interface")) K = CXCursor_ObjCInterfaceDecl; |
| 259 | else if (!strcmp(filter, "protocol")) K = CXCursor_ObjCProtocolDecl; |
| 260 | else if (!strcmp(filter, "function")) K = CXCursor_FunctionDecl; |
| 261 | else if (!strcmp(filter, "typedef")) K = CXCursor_TypedefDecl; |
| 262 | else { |
| 263 | fprintf(stderr, "Unknown filter for -test-load-tu: %s\n", filter); |
| 264 | return 1; |
Steve Naroff | f7469a3 | 2009-09-23 20:00:53 +0000 | [diff] [blame] | 265 | } |
Ted Kremenek | f5d9c93 | 2009-11-17 18:09:14 +0000 | [diff] [blame^] | 266 | |
| 267 | clang_loadTranslationUnit(TU, TranslationUnitVisitor, ck); |
| 268 | clang_disposeTranslationUnit(TU); |
| 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | static void print_usage(void) { |
| 273 | fprintf(stderr, |
| 274 | "usage: c-index-test -code-completion-at=<site> <compiler arguments>\n" |
| 275 | " c-index-test -test-load-tu <AST file> <symbol filter>\n\n" |
| 276 | " <symbol filter> options for -test-load-tu:\n%s", |
| 277 | " all - load all symbols, including those from PCH\n" |
| 278 | " local - load all symbols except those in PCH\n" |
| 279 | " category - only load ObjC categories (non-PCH)\n" |
| 280 | " interface - only load ObjC interfaces (non-PCH)\n" |
| 281 | " protocol - only load ObjC protocols (non-PCH)\n" |
| 282 | " function - only load functions (non-PCH)\n" |
| 283 | " typedef - only load typdefs (non-PCH)\n\n"); |
| 284 | } |
| 285 | |
| 286 | int main(int argc, const char **argv) { |
| 287 | if (argc > 2 && strstr(argv[1], "-code-completion-at=") == argv[1]) |
| 288 | return perform_code_completion(argc, argv); |
| 289 | if (argc == 4 && strcmp(argv[1], "-test-load-tu") == 0) |
| 290 | return perform_test_load_tu(argv[2], argv[3]); |
| 291 | |
| 292 | print_usage(); |
| 293 | return 1; |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 294 | } |