Gather cached code completions after the first reparse, not after the
second reparse.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121413 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 97e0326..d042f3f 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -848,6 +848,14 @@
   }
 
   Invocation.reset(Clang.takeInvocation());
+
+  if (ShouldCacheCodeCompletionResults) {
+    if (CacheCodeCompletionCoolDown > 0)
+      --CacheCodeCompletionCoolDown;
+    else if (top_level_size() != NumTopLevelDeclsAtLastCompletionCache)
+      CacheCodeCompletionResults();
+  }
+
   return false;
   
 error:
@@ -1586,14 +1594,6 @@
   
   // Parse the sources
   bool Result = Parse(OverrideMainBuffer);  
-  
-  if (ShouldCacheCodeCompletionResults) {
-    if (CacheCodeCompletionCoolDown > 0)
-      --CacheCodeCompletionCoolDown;
-    else if (top_level_size() != NumTopLevelDeclsAtLastCompletionCache)
-      CacheCodeCompletionResults();
-  }
-  
   return Result;
 }