diff options
author | Sam McCall <sam.mccall@gmail.com> | 2021-12-27 20:42:11 +0100 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2022-01-03 20:14:59 +0100 |
commit | 92417eaf3329dc823c905ec6a608b83ac62b4f7c (patch) | |
tree | bcfd0d918088aaddee36fe7a53b37d3a1f49e017 /clang/lib/Parse/ParseDecl.cpp | |
parent | a390c9905d4d1e7a7437fc1ab57f720c06618d79 (diff) | |
download | llvm-92417eaf3329dc823c905ec6a608b83ac62b4f7c.zip llvm-92417eaf3329dc823c905ec6a608b83ac62b4f7c.tar.gz llvm-92417eaf3329dc823c905ec6a608b83ac62b4f7c.tar.bz2 |
[CodeCompletion] Signature help for braced constructor calls
Implementation is based on the "expected type" as used for
designated-initializers in braced init lists. This means it can deduce the type
in some cases where it's not written:
void foo(Widget);
foo({ /*help here*/ });
Only basic constructor calls are in scope of this patch, excluded are:
- aggregate initialization (no help is offered for aggregates)
- initializer_list initialization (no help is offered for these constructors)
Fixes https://github.com/clangd/clangd/issues/306
Differential Revision: https://reviews.llvm.org/D116317
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 0c1f88b..5900075 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2420,7 +2420,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes( auto RunSignatureHelp = [&]() { QualType PreferredType = Actions.ProduceConstructorSignatureHelp( getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(), - ThisDecl->getLocation(), Exprs, T.getOpenLocation()); + ThisDecl->getLocation(), Exprs, T.getOpenLocation(), + /*Braced=*/false); CalledSignatureHelp = true; return PreferredType; }; @@ -2440,7 +2441,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes( if (ThisVarDecl && PP.isCodeCompletionReached() && !CalledSignatureHelp) { Actions.ProduceConstructorSignatureHelp( getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(), - ThisDecl->getLocation(), Exprs, T.getOpenLocation()); + ThisDecl->getLocation(), Exprs, T.getOpenLocation(), + /*Braced=*/false); CalledSignatureHelp = true; } Actions.ActOnInitializerError(ThisDecl); |