diff --git a/clang-tools-extra/clangd/SemanticHighlighting.h b/clang-tools-extra/clangd/SemanticHighlighting.h --- a/clang-tools-extra/clangd/SemanticHighlighting.h +++ b/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. diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -154,6 +154,8 @@ return HighlightingKind::TemplateParameter; if (isa(D)) return HighlightingKind::Concept; + if (isa(D)) + return HighlightingKind::Label; if (const auto *UUVD = dyn_cast(D)) { auto Targets = Resolver->resolveUsingValueDecl(UUVD); if (!Targets.empty()) { @@ -1212,6 +1214,8 @@ return OS << "Operator"; case HighlightingKind::Bracket: return OS << "Bracket"; + case HighlightingKind::Label: + return OS << "Label"; case HighlightingKind::InactiveCode: return OS << "InactiveCode"; } @@ -1352,6 +1356,8 @@ return "operator"; case HighlightingKind::Bracket: return "bracket"; + case HighlightingKind::Label: + return "label"; case HighlightingKind::InactiveCode: return "comment"; } diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -1025,6 +1025,16 @@ template $Bracket[[<]]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]] {