[clang] Make sure codecompletion is called for calls even when inside a token.

Summary:
Currently CodeCompleteCall only gets called after a comma or parantheses. This
patch makes sure it is called even at the cases like:
```foo(1^);```

Reviewers: ilya-biryukov, ioeric, hokein

Reviewed By: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D51038

llvm-svn: 341824
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index d3bb2bb..0c14f62 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1652,6 +1652,7 @@
       if (Tok.is(tok::code_completion)) {
         QualType PreferredType = Actions.ProduceCallSignatureHelp(
             getCurScope(), LHS.get(), None, PT.getOpenLocation());
+        CalledSignatureHelp = true;
         Actions.CodeCompleteExpression(getCurScope(), PreferredType);
         cutOffParsing();
         return ExprError();
@@ -1662,9 +1663,19 @@
           if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
                 QualType PreferredType = Actions.ProduceCallSignatureHelp(
                     getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
+                CalledSignatureHelp = true;
                 Actions.CodeCompleteExpression(getCurScope(), PreferredType);
               })) {
             (void)Actions.CorrectDelayedTyposInExpr(LHS);
+            // If we got an error when parsing expression list, we don't call
+            // the CodeCompleteCall handler inside the parser. So call it here
+            // to make sure we get overload suggestions even when we are in the
+            // middle of a parameter.
+            if (PP.isCodeCompletionReached() && !CalledSignatureHelp) {
+              Actions.ProduceCallSignatureHelp(getCurScope(), LHS.get(),
+                                               ArgExprs, PT.getOpenLocation());
+              CalledSignatureHelp = true;
+            }
             LHS = ExprError();
           } else if (LHS.isInvalid()) {
             for (auto &E : ArgExprs)