[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 10 01:16:54 PDT 2018
ilya-biryukov added a comment.
> Currently the problem is, there are again some tests out there that rely on
> CodeCompeleteOrdinaryName to be called even when getting overloads at an unknown
> parameter type
CodeCompleteExpression works just fine there. Unknown parameter type should not block code completion.
The idea is that anywhere except the start of the argument expression, we need to call **only** signature help. At the start of the argument, we have to call both signature help and code completion.
All existing tests pass with the following diff:
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -1659,12 +1659,19 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (OpKind == tok::l_paren || !LHS.isInvalid()) {
if (Tok.isNot(tok::r_paren)) {
- if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
- QualType PreferredType = Actions.ProduceCallSignatureHelp(
- getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
- Actions.CodeCompleteExpression(getCurScope(), PreferredType);
- })) {
+ auto Completer = [&] {
+ QualType PreferredType = Actions.ProduceCallSignatureHelp(
+ getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
+ Actions.CodeCompleteExpression(getCurScope(), PreferredType);
+ CalledOverloadCompletion = true;
+ };
+ if (ParseExpressionList(ArgExprs, CommaLocs, Completer)) {
(void)Actions.CorrectDelayedTyposInExpr(LHS);
+ if (PP.isCodeCompletionReached() && !CalledOverloadCompletion) {
+ CalledOverloadCompletion = true;
+ Actions.ProduceCallSignatureHelp(
+ getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation());
+ }
LHS = ExprError();
} else if (LHS.isInvalid()) {
for (auto &E : ArgExprs)
Please note there are other places where signature help methods (ProduceCallSignatureHelp and ProduceConstructorSignatureHelp) are called, we need to handle all of them. List of files that have those calls:
- lib/Parse/ParseExprCXX.cpp
- lib/Parse/ParseOpenMP.cpp
- lib/Parse/ParseExpr.cpp
- lib/Parse/ParseDecl.cpp
================
Comment at: include/clang/Parse/Parser.h:219
+ /// make sure CodeComleteCall is only called at the deepest level.
+ bool CalledOverloadCompletion = false;
+
----------------
NIT: rename to `CalledSignatureHelp`, this shouldn't affect completion
Repository:
rC Clang
https://reviews.llvm.org/D51038
More information about the cfe-commits
mailing list