[PATCH] D143260: [clangd] Add semantic token for labels
Christian Kandeler via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 7 03:28:22 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe72baa76b91f: [clangd] Add semantic token for labels (authored by ckandeler).
Changed prior to commit:
https://reviews.llvm.org/D143260?vs=494583&id=529234#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143260/new/
https://reviews.llvm.org/D143260
Files:
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1028,6 +1028,16 @@
template $Bracket[[<]]$Concept[[C2]]$Bracket[[<]]int$Bracket[[>]] $TemplateParameter_def[[A]]$Bracket[[>]]
class $Class_def[[B]] {};
)cpp",
+ // Labels
+ R"cpp(
+ bool $Function_def[[funcWithGoto]](bool $Parameter_def[[b]]) {
+ if ($Parameter[[b]])
+ goto $Label[[return_true]];
+ return false;
+ $Label_decl[[return_true]]:
+ return true;
+ }
+ )cpp",
// no crash
R"cpp(
struct $Class_def[[Foo]] {
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -52,6 +52,7 @@
Modifier,
Operator,
Bracket,
+ Label,
// This one is different from the other kinds as it's a line style
// rather than a token style.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -166,6 +166,8 @@
return HighlightingKind::TemplateParameter;
if (isa<ConceptDecl>(D))
return HighlightingKind::Concept;
+ if (isa<LabelDecl>(D))
+ return HighlightingKind::Label;
if (const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(D)) {
auto Targets = Resolver->resolveUsingValueDecl(UUVD);
if (!Targets.empty() && Targets[0] != UUVD) {
@@ -1271,6 +1273,8 @@
return OS << "Operator";
case HighlightingKind::Bracket:
return OS << "Bracket";
+ case HighlightingKind::Label:
+ return OS << "Label";
case HighlightingKind::InactiveCode:
return OS << "InactiveCode";
}
@@ -1470,6 +1474,8 @@
return "operator";
case HighlightingKind::Bracket:
return "bracket";
+ case HighlightingKind::Label:
+ return "label";
case HighlightingKind::InactiveCode:
return "comment";
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143260.529234.patch
Type: text/x-patch
Size: 2314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230607/bc4c1553/attachment.bin>
More information about the cfe-commits
mailing list