Move caching of code-completion results from ASTUnit::Reparse to ASTUnit::CodeComplete,

so that it will happen when we are doing code-completion, not reparsing.

llvm-svn: 143342
This commit is contained in:
Argyrios Kyrtzidis 2011-10-31 07:20:19 +00:00
parent 6fb6003aad
commit 1b544e3cf0
1 changed files with 6 additions and 6 deletions

View File

@ -1942,12 +1942,6 @@ bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) {
// Parse the sources
bool Result = Parse(OverrideMainBuffer);
// If we're caching global code-completion results, and the top-level
// declarations have changed, clear out the code-completion cache.
if (!Result && ShouldCacheCodeCompletionResults &&
CurrentTopLevelHashValue != CompletionCacheTopLevelHashValue)
CacheCodeCompletionResults();
// We now need to clear out the completion allocator for
// clang_getCursorCompletionString; it'll be recreated if necessary.
@ -2207,6 +2201,12 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers) {
if (!Invocation)
return;
// If we're caching global code-completion results, and the top-level
// declarations have changed, clear out the code-completion cache.
if (ShouldCacheCodeCompletionResults &&
CurrentTopLevelHashValue != CompletionCacheTopLevelHashValue)
CacheCodeCompletionResults();
SimpleTimer CompletionTimer(WantTiming);
CompletionTimer.setOutput("Code completion @ " + File + ":" +