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 | ec6762c709726bf2ee5f76c21df81e71a56e6f81 (patch) | |
tree | f82b41260987217209885cb4bf07242d0aae5a9f /tools/c-index-test/c-index-test.c | |
parent | 4273f7068f16863f2469b45a3f00c3b4217bdbb4 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91690 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/c-index-test/c-index-test.c')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 7040a7288a..f3458adda8 100644 --- a/tools/c-index-test/c-index-test.c +++ b/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); |