[PATCH] D62238: [CodeComplete] Complete a lambda when preferred type is a function
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 22 06:13:04 PDT 2019
ilya-biryukov marked an inline comment as done and an inline comment as not done.
ilya-biryukov added inline comments.
================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:4135
+ !PotentialTemplateName.getAsIdentifierInfo()->getName().contains(
+ "function"))
+ return nullptr;
----------------
kadircet wrote:
> This looks cheesy, do we really want to perform this operation only for templates with `"function"` in their names?
>
> As discussed offline maybe perform this for any template with a single(non-defaulted?) argument, or maybe even better perform a type-check as suggested by you. But I believe there would be too many false positives with the current state.
WDYT about `"function"` + only template with a single arg?
FWIW, I think function in template arguments are very rare, so I'm more optimistic about false-positives even in the current form.
We have an option of making it super-restrictive and only firing on whitelisted things like `std::function`, `boost::function`, etc.
But we don't have a mechanism to configure those from the outside, so that will probably turn out too restrictive.
================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:4154
+ Results.getCodeCompletionTUInfo());
+ // [](<parameters>) {}
+ Completion.AddChunk(CodeCompletionString::CK_LeftBracket);
----------------
kadircet wrote:
> maybe also add a placeholder for captures?
Done. With `=` as a default.
I'd personally rather have less placeholders, but I guess that might be useful.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62238/new/
https://reviews.llvm.org/D62238
More information about the cfe-commits
mailing list