Uses a heuristic to detect std::function and friends.
Details
- Reviewers
kadircet - Commits
- rZORG511aeea3f836: [CodeComplete] Complete a lambda when preferred type is a function
rG511aeea3f836: [CodeComplete] Complete a lambda when preferred type is a function
rG3a2f0e466b58: [CodeComplete] Complete a lambda when preferred type is a function
rC361461: [CodeComplete] Complete a lambda when preferred type is a function
rL361461: [CodeComplete] Complete a lambda when preferred type is a function
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang/lib/Sema/SemaCodeComplete.cpp | ||
---|---|---|
4135 ↗ | (On Diff #200677) | 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. |
4154 ↗ | (On Diff #200677) | maybe also add a placeholder for captures? |
- Add placeholder for captures.
- Only accept classes that have exactly one template argument.
clang/lib/Sema/SemaCodeComplete.cpp | ||
---|---|---|
4135 ↗ | (On Diff #200677) | WDYT about "function" + only template with a single arg? We have an option of making it super-restrictive and only firing on whitelisted things like std::function, boost::function, etc. |
4154 ↗ | (On Diff #200677) | Done. With = as a default. |
clang/lib/Sema/SemaCodeComplete.cpp | ||
---|---|---|
4125 ↗ | (On Diff #200717) | I thought you decided to get rid of this branch after the offline discussions, sorry for not mentioning in earlier revision. |
4142 ↗ | (On Diff #200717) | what about referencetype? void test(); void (&y)() = test; |
4135 ↗ | (On Diff #200677) | I don't think adding "function" as a restriction is helping much on reducing false positives. I would rather get rid of that check to increase usability. The real problem is rather checking constructors to make sure there is at least one for which we can provide a callable with the signature we found. Anything else just seems cheesy and might result in people adding more and more cases over time. It is up to you, I am OK if you choose to keep this restriction as well. |
- Only work on sugared types
- Do not check for 'function' in the name
clang/lib/Sema/SemaCodeComplete.cpp | ||
---|---|---|
4125 ↗ | (On Diff #200717) | Sorry, my bad, forgot about it. |
4142 ↗ | (On Diff #200717) | Lambdas are r-values, so suggesting them for l-value references would lead to an error. |
4135 ↗ | (On Diff #200677) | Removed the restriction on the function way. |