Improve code completion in failure cases in two ways:
  1) Suppress diagnostics as soon as we form the code-completion
  token, so we don't get any error/warning spew from the early
  end-of-file.
  2) If we consume a code-completion token when we weren't expecting
  one, go into a code-completion recovery path that produces the best
  results it can based on the context that the parser is in.

llvm-svn: 104585
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 036ae7e..1685cd5 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -843,6 +843,7 @@
   case Action::CCC_Statement:
   case Action::CCC_ForInit:
   case Action::CCC_Condition:
+  case Action::CCC_RecoveryInFunction:
     break;
   }
 }
@@ -994,6 +995,7 @@
     AddObjCVisibilityResults(SemaRef.getLangOptions(), Results, true);
     break;
       
+  case Action::CCC_RecoveryInFunction:
   case Action::CCC_Statement: {
     Results.AddResult(Result("typedef"));
 
@@ -1925,6 +1927,10 @@
   case CCC_Condition:
     Results.setFilter(&ResultBuilder::IsOrdinaryName);
     break;
+      
+  case CCC_RecoveryInFunction:
+    // Unfiltered
+    break;
   }
 
   CodeCompletionDeclConsumer Consumer(Results, CurContext);
@@ -3079,8 +3085,6 @@
   }
 
   Results.ExitScope();
-  
-  // This also suppresses remaining diagnostics.
   HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
 }