Prior to this patch, CollectExtraHighlightings would incorrectly produce
a token for the init-capture's type which overlapped the name and
resulted in both being dropped.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
522 | Note, I initially tried D->getTypeSpecStartLoc() != D->getTypeSpecEndLoc(), but it turns out they are equal both in the init-capture case and in the regular auto case, so that check cannot be used to discriminate between the two. |
Naming of the patch is a little bit confusing. We're actually dropping the semantic highlighting for the type of lambdacaptures, which was showing up in the declarator names since there was no explicit type spelled in the source code. This turns on highlighting for the capture variables because we're left with a single token now.
Can you reword the description to reflect that?
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
515 | nit: while here do you mind turning this into an early exit as well? the nesting below seems a little distracting. | |
522 | why not just check if D is implicit? |
Updated patch description. (Also, I forgot to link to https://github.com/clangd/clangd/issues/868 which contains additional context, sorry!)
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
522 | If you mean D->isImplicit(), that returns false for init-captures. |
thanks, LGTM!
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
515 | sorry I was also talking about also turning if(auto K = ...) to auto K = ... if (!K) return true; | |
517 | i think the comment might be more explicit about doing this to ensure we are not attributing the highlighting to some closeby token. | |
522 | ah nvm, I was looking at the fielddecl implicitly introduced into the lambda, not the vardecl that was created with the capture (https://github.com/llvm/llvm-project/tree/main/clang/lib/Sema/SemaLambda.cpp#L1739). |
nit: while here do you mind turning this into an early exit as well? the nesting below seems a little distracting.