ckandeler created this revision. ckandeler added a reviewer: sammccall. Herald added subscribers: kadircet, arphaman. Herald added a project: All. ckandeler requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra.
Repository: rG LLVM Github Monorepo 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 @@ -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]] { 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 @@ -154,6 +154,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()) { @@ -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"; }
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ 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]] { 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 @@ -154,6 +154,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()) { @@ -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"; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits