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