diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-18 16:20:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-18 16:20:58 +0000 |
commit | f72b6ac87fa59a3aa2d7a8081a6913619a83f957 (patch) | |
tree | 3ea697d2bb3d8aa30da312d9e509311aefa685b3 /clang/tools/c-index-test/c-index-test.c | |
parent | 01e620efaab4a43d3a0363f11ba9270ec2b29a78 (diff) | |
download | bcm5719-llvm-f72b6ac87fa59a3aa2d7a8081a6913619a83f957.tar.gz bcm5719-llvm-f72b6ac87fa59a3aa2d7a8081a6913619a83f957.zip |
Change clang_codeComplete API to return the results in a structure on
the heap, so that clients are not forced to copy the results during
the initial iteration. A separate clang_disposeCodeCompleteResults
function frees the returned results.
llvm-svn: 91690
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 7040a7288a1..f3458adda8e 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -496,6 +496,7 @@ int perform_code_completion(int argc, const char **argv) { int errorCode; struct CXUnsavedFile *unsaved_files = 0; int num_unsaved_files = 0; + CXCodeCompleteResults *results = 0; input += strlen("-code-completion-at="); if ((errorCode = parse_file_line_column(input, &filename, &line, &column))) @@ -505,10 +506,18 @@ int perform_code_completion(int argc, const char **argv) { return -1; CIdx = clang_createIndex(0, 0); - clang_codeComplete(CIdx, argv[argc - 1], argc - num_unsaved_files - 3, - argv + num_unsaved_files + 2, - num_unsaved_files, unsaved_files, - filename, line, column, &print_completion_result, stdout); + results = clang_codeComplete(CIdx, + argv[argc - 1], argc - num_unsaved_files - 3, + argv + num_unsaved_files + 2, + num_unsaved_files, unsaved_files, + filename, line, column); + if (results) { + unsigned i, n = results->NumResults; + for (i = 0; i != n; ++i) + print_completion_result(results->Results + i, stdout); + clang_disposeCodeCompleteResults(results); + } + clang_disposeIndex(CIdx); free(filename); |