blob: 3a16fcadbbbce3387d53815d02b86399ee8b031e [file] [log] [blame]
Steve Naroff2b8ee6c2009-09-01 15:55:40 +00001/* c-index-test.c */
Steve Naroff50398192009-08-28 15:28:48 +00002
3#include "clang-c/Index.h"
Douglas Gregor0c8296d2009-11-07 00:00:49 +00004#include <stdlib.h>
Steve Naroff89922f82009-08-31 00:59:03 +00005#include <stdio.h>
Steve Naroffaf08ddc2009-09-03 15:49:00 +00006#include <string.h>
7
Ted Kremenek0d435192009-11-17 18:13:31 +00008/******************************************************************************/
9/* Utility functions. */
10/******************************************************************************/
11
John Thompson2e06fc82009-10-27 13:42:56 +000012#ifdef _MSC_VER
13char *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 Naroffff9e18c2009-09-24 20:03:06 +000027extern char *basename(const char *);
John Thompson2e06fc82009-10-27 13:42:56 +000028#endif
Steve Naroffff9e18c2009-09-24 20:03:06 +000029
Ted Kremenek1c6da172009-11-17 19:37:36 +000030static unsigned CreateTranslationUnit(CXIndex Idx, const char *file,
31 CXTranslationUnit *TU) {
32
33 *TU = clang_createTranslationUnit(Idx, file);
34 if (!TU) {
35 fprintf(stderr, "Unable to load translation unit from '%s'!\n", file);
36 return 0;
37 }
38 return 1;
39}
40
41
Ted Kremenek0d435192009-11-17 18:13:31 +000042/******************************************************************************/
43/* Pretty-printing. */
44/******************************************************************************/
45
Steve Naroffaf08ddc2009-09-03 15:49:00 +000046static void PrintCursor(CXCursor Cursor) {
Steve Naroff77128dd2009-09-15 20:25:34 +000047 if (clang_isInvalid(Cursor.kind))
Ted Kremenek1c6da172009-11-17 19:37:36 +000048 printf("Invalid Cursor => %s", clang_getCursorKindSpelling(Cursor.kind));
Steve Naroff699a07d2009-09-25 21:32:34 +000049 else {
Eric Christopherf393c3b2009-10-05 21:33:42 +000050 CXDecl DeclReferenced;
Steve Naroffef0cef62009-11-09 17:45:52 +000051 CXString string;
52 string = clang_getCursorSpelling(Cursor);
Steve Naroffff9e18c2009-09-24 20:03:06 +000053 printf("%s=%s", clang_getCursorKindSpelling(Cursor.kind),
Steve Naroffef0cef62009-11-09 17:45:52 +000054 clang_getCString(string));
55 clang_disposeString(string);
Eric Christopherf393c3b2009-10-05 21:33:42 +000056 DeclReferenced = clang_getCursorDecl(Cursor);
Steve Naroff85e2db72009-10-01 00:31:07 +000057 if (DeclReferenced)
58 printf(":%d:%d", clang_getDeclLine(DeclReferenced),
59 clang_getDeclColumn(DeclReferenced));
Steve Naroff699a07d2009-09-25 21:32:34 +000060 }
Steve Naroffaf08ddc2009-09-03 15:49:00 +000061}
Steve Naroff89922f82009-08-31 00:59:03 +000062
Ted Kremenek9298cfc2009-11-17 05:31:58 +000063static const char* GetCursorSource(CXCursor Cursor) {
64 const char *source = clang_getCursorSource(Cursor);
65 if (!source)
66 return "<invalid loc>";
67 return basename(source);
68}
69
Ted Kremenek0d435192009-11-17 18:13:31 +000070/******************************************************************************/
71/* Logic for testing clang_loadTranslationUnit(). */
72/******************************************************************************/
73
Eric Christopherf393c3b2009-10-05 21:33:42 +000074static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter)
Steve Naroffc857ea42009-09-02 13:28:54 +000075{
Daniel Dunbarbce6f622009-09-03 05:59:50 +000076 if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
Steve Naroffef0cef62009-11-09 17:45:52 +000077 CXString string;
Ted Kremenek9298cfc2009-11-17 05:31:58 +000078 printf("// CHECK: %s:%d:%d: ", GetCursorSource(Cursor),
Steve Naroffff9e18c2009-09-24 20:03:06 +000079 clang_getCursorLine(Cursor),
80 clang_getCursorColumn(Cursor));
Steve Naroffaf08ddc2009-09-03 15:49:00 +000081 PrintCursor(Cursor);
Steve Naroffef0cef62009-11-09 17:45:52 +000082 string = clang_getDeclSpelling(Dcl);
83 printf(" [Context=%s]\n", clang_getCString(string));
84 clang_disposeString(string);
Daniel Dunbarbce6f622009-09-03 05:59:50 +000085 }
Steve Naroffc857ea42009-09-02 13:28:54 +000086}
87static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
Eric Christopherf393c3b2009-10-05 21:33:42 +000088 CXClientData Filter)
Steve Naroffc857ea42009-09-02 13:28:54 +000089{
90 if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
Steve Naroffef0cef62009-11-09 17:45:52 +000091 CXString string;
Ted Kremenek9298cfc2009-11-17 05:31:58 +000092 printf("// CHECK: %s:%d:%d: ", GetCursorSource(Cursor),
Steve Naroffff9e18c2009-09-24 20:03:06 +000093 clang_getCursorLine(Cursor),
94 clang_getCursorColumn(Cursor));
Steve Naroffaf08ddc2009-09-03 15:49:00 +000095 PrintCursor(Cursor);
Steve Naroffef0cef62009-11-09 17:45:52 +000096 string = clang_getTranslationUnitSpelling(Unit);
97 printf(" [Context=%s]\n",
98 basename(clang_getCString(string)));
99 clang_disposeString(string);
Steve Naroffff9e18c2009-09-24 20:03:06 +0000100
101 clang_loadDeclaration(Cursor.decl, DeclVisitor, 0);
Steve Naroffc857ea42009-09-02 13:28:54 +0000102
Steve Naroff4ade6d62009-09-23 17:52:52 +0000103 if (Cursor.kind == CXCursor_FunctionDefn) {
104 const char *startBuf, *endBuf;
105 unsigned startLine, startColumn, endLine, endColumn;
106 clang_getDefinitionSpellingAndExtent(Cursor, &startBuf, &endBuf,
107 &startLine, &startColumn,
108 &endLine, &endColumn);
Steve Narofff7469a32009-09-23 20:00:53 +0000109 {
110 /* Probe the entire body, looking for both decls and refs. */
111 unsigned curLine = startLine, curColumn = startColumn;
112 CXCursor Ref;
Eric Christopherf393c3b2009-10-05 21:33:42 +0000113
Steve Naroff6a6de8b2009-10-21 13:56:23 +0000114 while (startBuf < endBuf) {
Steve Narofff7469a32009-09-23 20:00:53 +0000115 if (*startBuf == '\n') {
116 startBuf++;
117 curLine++;
118 curColumn = 1;
119 } else if (*startBuf != '\t')
120 curColumn++;
Ted Kremenekfbcb2b72009-10-22 17:22:53 +0000121
Steve Narofff96b5242009-10-28 20:44:47 +0000122 Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor),
123 curLine, curColumn);
Douglas Gregor02465752009-10-16 21:24:31 +0000124 if (Ref.kind == CXCursor_NoDeclFound) {
Ted Kremenek8ce88a42009-10-17 06:37:16 +0000125 /* Nothing found here; that's fine. */
Douglas Gregor02465752009-10-16 21:24:31 +0000126 } else if (Ref.kind != CXCursor_FunctionDecl) {
Steve Naroffef0cef62009-11-09 17:45:52 +0000127 CXString string;
Ted Kremenek9298cfc2009-11-17 05:31:58 +0000128 printf("// CHECK: %s:%d:%d: ", GetCursorSource(Ref),
129 curLine, curColumn);
Steve Narofff7469a32009-09-23 20:00:53 +0000130 PrintCursor(Ref);
Steve Naroffef0cef62009-11-09 17:45:52 +0000131 string = clang_getDeclSpelling(Ref.decl);
132 printf(" [Context:%s]\n", clang_getCString(string));
133 clang_disposeString(string);
Steve Narofff7469a32009-09-23 20:00:53 +0000134 }
Steve Naroff4ade6d62009-09-23 17:52:52 +0000135 startBuf++;
Steve Naroff4ade6d62009-09-23 17:52:52 +0000136 }
Steve Naroff4ade6d62009-09-23 17:52:52 +0000137 }
138 }
Steve Naroff2d4d6292009-08-31 14:26:51 +0000139 }
Steve Naroff89922f82009-08-31 00:59:03 +0000140}
Steve Naroff50398192009-08-28 15:28:48 +0000141
Ted Kremenek0d435192009-11-17 18:13:31 +0000142int perform_test_load_tu(const char *file, const char *filter) {
143 CXIndex Idx;
144 CXTranslationUnit TU;
145 enum CXCursorKind K = CXCursor_NotImplemented;
146 enum CXCursorKind *ck = &K;
147 Idx = clang_createIndex(/* excludeDeclsFromPCH */
148 !strcmp(filter, "local") ? 1 : 0,
149 /* displayDiagnostics */ 1);
150
Ted Kremenek1c6da172009-11-17 19:37:36 +0000151 if (!CreateTranslationUnit(Idx, file, &TU))
Ted Kremenek0d435192009-11-17 18:13:31 +0000152 return 1;
Ted Kremenek0d435192009-11-17 18:13:31 +0000153
154 /* Perform some simple filtering. */
155 if (!strcmp(filter, "all") || !strcmp(filter, "local")) ck = NULL;
156 else if (!strcmp(filter, "category")) K = CXCursor_ObjCCategoryDecl;
157 else if (!strcmp(filter, "interface")) K = CXCursor_ObjCInterfaceDecl;
158 else if (!strcmp(filter, "protocol")) K = CXCursor_ObjCProtocolDecl;
159 else if (!strcmp(filter, "function")) K = CXCursor_FunctionDecl;
160 else if (!strcmp(filter, "typedef")) K = CXCursor_TypedefDecl;
161 else {
162 fprintf(stderr, "Unknown filter for -test-load-tu: %s\n", filter);
163 return 1;
164 }
165
166 clang_loadTranslationUnit(TU, TranslationUnitVisitor, ck);
167 clang_disposeTranslationUnit(TU);
168 return 0;
169}
170
Daniel Dunbarada487d2009-12-01 02:03:10 +0000171int perform_test_load_source(int argc, const char **argv, const char *filter) {
172 CXIndex Idx;
173 CXTranslationUnit TU;
174 enum CXCursorKind K = CXCursor_NotImplemented;
175 enum CXCursorKind *ck = &K;
176 Idx = clang_createIndex(/* excludeDeclsFromPCH */
177 !strcmp(filter, "local") ? 1 : 0,
178 /* displayDiagnostics */ 1);
179
180 TU = clang_createTranslationUnitFromSourceFile(Idx, 0, argc, argv);
181 if (!TU) {
182 fprintf(stderr, "Unable to load translation unit!\n");
183 return 1;
184 }
185
186 /* Perform some simple filtering. */
187 if (!strcmp(filter, "all") || !strcmp(filter, "local")) ck = NULL;
188 else if (!strcmp(filter, "category")) K = CXCursor_ObjCCategoryDecl;
189 else if (!strcmp(filter, "interface")) K = CXCursor_ObjCInterfaceDecl;
190 else if (!strcmp(filter, "protocol")) K = CXCursor_ObjCProtocolDecl;
191 else if (!strcmp(filter, "function")) K = CXCursor_FunctionDecl;
192 else if (!strcmp(filter, "typedef")) K = CXCursor_TypedefDecl;
193 else {
194 fprintf(stderr, "Unknown filter for -test-load-tu: %s\n", filter);
195 return 1;
196 }
197
198 clang_loadTranslationUnit(TU, TranslationUnitVisitor, ck);
199 clang_disposeTranslationUnit(TU);
200 return 0;
201}
202
Ted Kremenek0d435192009-11-17 18:13:31 +0000203/******************************************************************************/
Ted Kremenek1c6da172009-11-17 19:37:36 +0000204/* Logic for testing clang_getCursor(). */
205/******************************************************************************/
206
207static void print_cursor_file_scan(CXCursor cursor,
208 unsigned start_line, unsigned start_col,
Ted Kremenek1d5fdf32009-11-18 02:02:52 +0000209 unsigned end_line, unsigned end_col,
210 const char *prefix) {
211 printf("// CHECK");
212 if (prefix)
213 printf("-%s", prefix);
214 printf("{start_line=%d start_col=%d end_line=%d end_col=%d} ",
215 start_line, start_col, end_line, end_col);
Ted Kremenek1c6da172009-11-17 19:37:36 +0000216 PrintCursor(cursor);
217 printf("\n");
218}
219
Ted Kremenek1d5fdf32009-11-18 02:02:52 +0000220static int perform_file_scan(const char *ast_file, const char *source_file,
221 const char *prefix) {
Ted Kremenek1c6da172009-11-17 19:37:36 +0000222 CXIndex Idx;
223 CXTranslationUnit TU;
224 FILE *fp;
225 unsigned line;
226 CXCursor prevCursor;
227 unsigned printed;
228 unsigned start_line, start_col, last_line, last_col;
229 size_t i;
230
231 if (!(Idx = clang_createIndex(/* excludeDeclsFromPCH */ 1,
232 /* displayDiagnostics */ 1))) {
233 fprintf(stderr, "Could not create Index\n");
234 return 1;
235 }
236
237 if (!CreateTranslationUnit(Idx, ast_file, &TU))
238 return 1;
239
240 if ((fp = fopen(source_file, "r")) == NULL) {
241 fprintf(stderr, "Could not open '%s'\n", source_file);
242 return 1;
243 }
244
245 line = 0;
246 prevCursor = clang_getNullCursor();
247 printed = 0;
248 start_line = last_line = 1;
249 start_col = last_col = 1;
250
251 while (!feof(fp)) {
Benjamin Kramera9933b92009-11-17 20:51:40 +0000252 size_t len = 0;
253 int c;
254
255 while ((c = fgetc(fp)) != EOF) {
256 len++;
257 if (c == '\n')
258 break;
259 }
260
Ted Kremenek1c6da172009-11-17 19:37:36 +0000261 ++line;
262
263 for (i = 0; i < len ; ++i) {
264 CXCursor cursor;
265 cursor = clang_getCursor(TU, source_file, line, i+1);
266
267 if (!clang_equalCursors(cursor, prevCursor) &&
268 prevCursor.kind != CXCursor_InvalidFile) {
269 print_cursor_file_scan(prevCursor, start_line, start_col,
Ted Kremenek1d5fdf32009-11-18 02:02:52 +0000270 last_line, last_col, prefix);
Ted Kremenek1c6da172009-11-17 19:37:36 +0000271 printed = 1;
272 start_line = line;
273 start_col = (unsigned) i+1;
274 }
275 else {
276 printed = 0;
277 }
278
279 prevCursor = cursor;
280 last_line = line;
281 last_col = (unsigned) i+1;
282 }
283 }
284
285 if (!printed && prevCursor.kind != CXCursor_InvalidFile) {
286 print_cursor_file_scan(prevCursor, start_line, start_col,
Ted Kremenek1d5fdf32009-11-18 02:02:52 +0000287 last_line, last_col, prefix);
Ted Kremenek1c6da172009-11-17 19:37:36 +0000288 }
289
290 fclose(fp);
291 return 0;
292}
293
294/******************************************************************************/
Ted Kremenek0d435192009-11-17 18:13:31 +0000295/* Logic for testing clang_codeComplete(). */
296/******************************************************************************/
297
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000298/* Parse file:line:column from the input string. Returns 0 on success, non-zero
299 on failure. If successful, the pointer *filename will contain newly-allocated
300 memory (that will be owned by the caller) to store the file name. */
301int parse_file_line_column(const char *input, char **filename, unsigned *line,
302 unsigned *column) {
Douglas Gregor88d23952009-11-09 18:19:57 +0000303 /* Find the second colon. */
304 const char *second_colon = strrchr(input, ':'), *first_colon;
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000305 char *endptr = 0;
Douglas Gregor88d23952009-11-09 18:19:57 +0000306 if (!second_colon || second_colon == input) {
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000307 fprintf(stderr, "could not parse filename:line:column in '%s'\n", input);
308 return 1;
309 }
310
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000311 /* Parse the column number. */
Douglas Gregor88d23952009-11-09 18:19:57 +0000312 *column = strtol(second_colon + 1, &endptr, 10);
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000313 if (*endptr != 0) {
314 fprintf(stderr, "could not parse column in '%s'\n", input);
Douglas Gregor88d23952009-11-09 18:19:57 +0000315 return 1;
316 }
317
318 /* Find the first colon. */
319 first_colon = second_colon - 1;
320 while (first_colon != input && *first_colon != ':')
321 --first_colon;
322 if (first_colon == input) {
323 fprintf(stderr, "could not parse line in '%s'\n", input);
324 return 1;
325 }
326
327 /* Parse the line number. */
328 *line = strtol(first_colon + 1, &endptr, 10);
329 if (*endptr != ':') {
330 fprintf(stderr, "could not parse line in '%s'\n", input);
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000331 return 1;
332 }
333
Douglas Gregor88d23952009-11-09 18:19:57 +0000334 /* Copy the file name. */
335 *filename = (char*)malloc(first_colon - input + 1);
336 memcpy(*filename, input, first_colon - input);
337 (*filename)[first_colon - input] = 0;
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000338 return 0;
339}
340
341const char *
342clang_getCompletionChunkKindSpelling(enum CXCompletionChunkKind Kind) {
343 switch (Kind) {
344 case CXCompletionChunk_Optional: return "Optional";
345 case CXCompletionChunk_TypedText: return "TypedText";
346 case CXCompletionChunk_Text: return "Text";
347 case CXCompletionChunk_Placeholder: return "Placeholder";
348 case CXCompletionChunk_Informative: return "Informative";
349 case CXCompletionChunk_CurrentParameter: return "CurrentParameter";
350 case CXCompletionChunk_LeftParen: return "LeftParen";
351 case CXCompletionChunk_RightParen: return "RightParen";
352 case CXCompletionChunk_LeftBracket: return "LeftBracket";
353 case CXCompletionChunk_RightBracket: return "RightBracket";
354 case CXCompletionChunk_LeftBrace: return "LeftBrace";
355 case CXCompletionChunk_RightBrace: return "RightBrace";
356 case CXCompletionChunk_LeftAngle: return "LeftAngle";
357 case CXCompletionChunk_RightAngle: return "RightAngle";
358 case CXCompletionChunk_Comma: return "Comma";
359 }
360
361 return "Unknown";
362}
363
Douglas Gregor3ac73852009-11-09 16:04:45 +0000364void print_completion_string(CXCompletionString completion_string, FILE *file) {
Daniel Dunbarf8297f12009-11-07 18:34:24 +0000365 int I, N;
Douglas Gregor3ac73852009-11-09 16:04:45 +0000366
367 N = clang_getNumCompletionChunks(completion_string);
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000368 for (I = 0; I != N; ++I) {
Douglas Gregord5a20892009-11-09 17:05:28 +0000369 const char *text = 0;
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000370 enum CXCompletionChunkKind Kind
Douglas Gregor3ac73852009-11-09 16:04:45 +0000371 = clang_getCompletionChunkKind(completion_string, I);
372
373 if (Kind == CXCompletionChunk_Optional) {
374 fprintf(file, "{Optional ");
375 print_completion_string(
376 clang_getCompletionChunkCompletionString(completion_string, I),
377 file);
378 fprintf(file, "}");
379 continue;
380 }
381
Douglas Gregord5a20892009-11-09 17:05:28 +0000382 text = clang_getCompletionChunkText(completion_string, I);
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000383 fprintf(file, "{%s %s}",
384 clang_getCompletionChunkKindSpelling(Kind),
385 text? text : "");
386 }
Douglas Gregor3ac73852009-11-09 16:04:45 +0000387}
388
389void print_completion_result(CXCompletionResult *completion_result,
390 CXClientData client_data) {
391 FILE *file = (FILE *)client_data;
392 fprintf(file, "%s:",
393 clang_getCursorKindSpelling(completion_result->CursorKind));
394 print_completion_string(completion_result->CompletionString, file);
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000395 fprintf(file, "\n");
396}
397
Ted Kremenekf5d9c932009-11-17 18:09:14 +0000398int perform_code_completion(int argc, const char **argv) {
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000399 const char *input = argv[1];
400 char *filename = 0;
401 unsigned line;
402 unsigned column;
Daniel Dunbarf8297f12009-11-07 18:34:24 +0000403 CXIndex CIdx;
Ted Kremenekf5d9c932009-11-17 18:09:14 +0000404 int errorCode;
Daniel Dunbarf8297f12009-11-07 18:34:24 +0000405
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000406 input += strlen("-code-completion-at=");
Ted Kremenekf5d9c932009-11-17 18:09:14 +0000407 if ((errorCode = parse_file_line_column(input, &filename, &line, &column)))
408 return errorCode;
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000409
Daniel Dunbarf8297f12009-11-07 18:34:24 +0000410 CIdx = clang_createIndex(0, 0);
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000411 clang_codeComplete(CIdx, argv[argc - 1], argc - 3, argv + 2,
412 filename, line, column, &print_completion_result, stdout);
413 clang_disposeIndex(CIdx);
414 free(filename);
Ted Kremenekf5d9c932009-11-17 18:09:14 +0000415
416 return 0;
Douglas Gregor0c8296d2009-11-07 00:00:49 +0000417}
418
Ted Kremenek0d435192009-11-17 18:13:31 +0000419/******************************************************************************/
420/* Command line processing. */
421/******************************************************************************/
Ted Kremenekf5d9c932009-11-17 18:09:14 +0000422
423static void print_usage(void) {
424 fprintf(stderr,
Ted Kremenek0d435192009-11-17 18:13:31 +0000425 "usage: c-index-test -code-completion-at=<site> <compiler arguments>\n"
Ted Kremenek1d5fdf32009-11-18 02:02:52 +0000426 " c-index-test -test-file-scan <AST file> <source file> "
427 "[FileCheck prefix]\n"
Ted Kremenek0d435192009-11-17 18:13:31 +0000428 " c-index-test -test-load-tu <AST file> <symbol filter>\n\n"
Daniel Dunbarada487d2009-12-01 02:03:10 +0000429 " c-index-test -test-load-source <symbol filter> {<args>}*\n\n"
430 " <symbol filter> options for -test-load-tu and -test-load-source:\n%s",
Ted Kremenek0d435192009-11-17 18:13:31 +0000431 " all - load all symbols, including those from PCH\n"
432 " local - load all symbols except those in PCH\n"
433 " category - only load ObjC categories (non-PCH)\n"
434 " interface - only load ObjC interfaces (non-PCH)\n"
435 " protocol - only load ObjC protocols (non-PCH)\n"
436 " function - only load functions (non-PCH)\n"
437 " typedef - only load typdefs (non-PCH)\n\n");
Ted Kremenekf5d9c932009-11-17 18:09:14 +0000438}
439
440int main(int argc, const char **argv) {
441 if (argc > 2 && strstr(argv[1], "-code-completion-at=") == argv[1])
442 return perform_code_completion(argc, argv);
443 if (argc == 4 && strcmp(argv[1], "-test-load-tu") == 0)
444 return perform_test_load_tu(argv[2], argv[3]);
Daniel Dunbarada487d2009-12-01 02:03:10 +0000445 if (argc >= 4 && strcmp(argv[1], "-test-load-source") == 0)
446 return perform_test_load_source(argc - 3, argv + 3, argv[2]);
Ted Kremenek1d5fdf32009-11-18 02:02:52 +0000447 if (argc >= 4 && strcmp(argv[1], "-test-file-scan") == 0)
448 return perform_file_scan(argv[2], argv[3],
449 argc >= 5 ? argv[4] : 0);
Ted Kremenekf5d9c932009-11-17 18:09:14 +0000450
451 print_usage();
452 return 1;
Steve Naroff50398192009-08-28 15:28:48 +0000453}