Bug 397205 - Lambda capture with initializers and structured binding declaration not parsed
Summary: Lambda capture with initializers and structured binding declaration not parsed
Status: RESOLVED UPSTREAM
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (other bugs)
Version First Reported In: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-06 09:00 UTC by Daniel Vrátil
Modified: 2020-04-15 15:48 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Highligted operator== with two unhighlighted variables (25.77 KB, image/png)
2018-10-12 02:59 UTC, Guillaume Racicot
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Vrátil 2018-08-06 09:00:05 UTC
Variables declared with lambda captures with initializers are not syntax-highlighted and are not part of code completion inside of the lambda.

[socket = std::weak_ptr<ISocket>(socketptr)]() {
    // "socket" is not available for code completion and when used the entire expression is not syntax-highlighted
};

Same applies to variables defined by structured binding.


I have the C++ profile set to C++1z in project settings and other C++14/17 constructs are highlighted correctly.
Comment 1 Guillaume Racicot 2018-10-12 02:59:18 UTC
Created attachment 115585 [details]
Highligted operator== with two unhighlighted variables

As with lambda capture, structured binding seems to behave as if the type of the variable is indeed recognized, but not the declaration. I added a screenshot that demonstrates that two unhighlighted variables (created from structured bindings) actually yield to highlighted expressions when it uses other entities.

I analyzed what libclang output as information, and it seems to skip declaration of such variable (structured bindings and lambda capture with initializers) but later uses those as if they were declared. This breaks the KDevelop DUChain, since the usages cannot be linked to a declaration.
Comment 2 Milian Wolff 2020-04-15 15:48:40 UTC
lambda captures with initializers got merged a while ago:
https://reviews.llvm.org/D60672

the c++17 stuff I added just now upstream:

structured binding:
https://reviews.llvm.org/D78213

if with init:
https://reviews.llvm.org/D78214