From 8e984da800594aefdeaf33da2f75cb66782f328e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 4 Aug 2010 16:47:14 +0000 Subject: Add code-completion support directly to ASTUnit, which performs code completion within the translation unit using the same command-line arguments for parsing the translation unit. Eventually, we'll reuse the precompiled preamble to improve code-completion performance, and this also gives us a place to cache results. Expose this function via the new libclang function clang_codeCompleteAt(), which performs the code completion within a CXTranslationUnit. The completion occurs in-process (clang_codeCompletion() runs code completion out-of-process). llvm-svn: 110210 --- clang/lib/Sema/SemaCodeComplete.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/Sema/SemaCodeComplete.cpp') diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 476c79cc37b..52ac8dd6498 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -1811,13 +1811,15 @@ static void AddFunctionTypeQualsToCompletionString(CodeCompletionString *Result, /// how to use this result, or NULL to indicate that the string or name of the /// result is all that is needed. CodeCompletionString * -CodeCompleteConsumer::Result::CreateCodeCompletionString(Sema &S) { +CodeCompleteConsumer::Result::CreateCodeCompletionString(Sema &S, + CodeCompletionString *Result) { typedef CodeCompletionString::Chunk Chunk; if (Kind == RK_Pattern) - return Pattern->Clone(); + return Pattern->Clone(Result); - CodeCompletionString *Result = new CodeCompletionString; + if (!Result) + Result = new CodeCompletionString; if (Kind == RK_Keyword) { Result->AddTypedTextChunk(Keyword); -- cgit v1.2.3