Bug 397205

Summary: Lambda capture with initializers and structured binding declaration not parsed
Product: [Applications] kdevelop Reporter: Daniel Vrátil <dvratil>
Component: Language Support: CPP (Clang-based)Assignee: kdevelop-bugs-null
Status: RESOLVED UPSTREAM    
Severity: normal CC: gufideg
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Highligted operator== with two unhighlighted variables

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